Deserializing response
I am using RestRequest to do a POST to a web service. The response is in JSON format, but I receive it in response. Content is ASCII and Data is null. code:
var request = new RestRequest(api, Method.POST);
request.RequestFormat = DataFormat.Json;
request.AddObject(data);
RestClient client = new RestClient("http://IP:PORT/proto");
client.ExecuteAsync<jLoginResponse>(request, (response) =>
{
var resource = response.Data;
});
and here response.Data is empty and Content is {"UID": "1234"}
jLoginResponse is declared as
[DataContract]
public class jLoginResponse
{
public string uid { get; set; }
}
but it will not be automatically deserialized as it should.
+3
source to share