Note that there are some explanatory texts on larger screens.

plurals
  1. PORest service messing up strings with double quotes
    primarykey
    data
    text
    <p>Note that my question is similar to <a href="https://stackoverflow.com/questions/13602472/encoding-issue-service-stack-quotes-and-angle-bracket-being-stripped/14219903#14219903">this question</a> but since I can't figure out how to add a comment to the accepted answer asking for clarification, I have to create a new question.</p> <p>I have a rest service, similar to this:</p> <pre><code>namespace My.API { [Route("/event/{Id}", Verbs = "POST")] public class EventRequest { public int Id { get; set; } public string Content { get; set; } } public class EventService : Service { public object Post(EventRequest request) { // Do something with request.Content } } } </code></pre> <p>When I make a post request with the following form data:</p> <pre><code>Content=%22this+is+a+%22+test </code></pre> <p>request.Content contains</p> <pre><code>this is a " tes </code></pre> <p>Note that the first doublequote is missing, and the t at the end of test is missing.</p> <p>Now, the accepted answer in the other question linked above says that we need to encode the string, but I am wondering if there is anyway that I can change the behaviour of this. I am trying to create a public api, and if the clients of the api have to encode the string in a certain way then I think that will cause errors. They should just be able to provide a normal string.</p> <p>Basically, the following jQuery ajax call should work:</p> <pre><code>$.ajax({ url: "api/event/" + id, type: "POST", data: {Content : content} }); </code></pre> <p>Where content is the raw/unencoded string, which jQuery will perform form url encoding on before passing to the service. The service should just return the original raw string.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload