We are having an issue with IRestRequest. When trying to consume a JSON request, if there is a & in a Json String, IRestRequest is breaking the request Form input more then 1 variable which is causing issues.
How can we resolve this?
We are having an issue with IRestRequest. When trying to consume a JSON request, if there is a & in a Json String, IRestRequest is breaking the request Form input more then 1 variable which is causing issues.
How can we resolve this?
Are you passing the correct content type to the endpoint? Are you porperly encoding your JSON data? The screenshot does not really help, you will need to share your code, data and a trace
Also if you are accepting JSON, why are you reading request.Form? If you are passing in JSON as the request, you need to read the body raw then deserialize
How do we access the raw body?
So do not read the Form, read the body into a Stream/String then deserialze. Also JSON is not UrlEncoded, it will need specific Javascript encoding.
It the Reques's input stream
specifically IRestRequest.Request.InputStream
public static string GetDocumentContents(System.Web.HttpRequestBase request) { // reset the stream position as telligent has already read the input stream if (request.InputStream.CanRead && request.InputStream.CanSeek) { request.InputStream.Position = 0; } else { throw new Exception("Unable to reset input stream"); } string documentContents; using (Stream receiveStream = request.InputStream) { using (StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8)) { documentContents = readStream.ReadToEnd(); } } return documentContents; }