I currently tried to get serialized response from a RestSharp PostAsync call like in
var responseData = Client.PostAsync<Data>(request).Result;
Now, this is what I receive:
{
"status":1,
"success":"message transmitted",
"available":19215,
"message_ids":"26684730:56798"
}
and this is the "Data" class:
public class Data
{
[JsonProperty("status")]
public int Status { get; set; }
[JsonProperty("success")]
public string Success { get; set; }
[JsonProperty("available")]
public int Available { get; set; }
[JsonProperty("message_ids")]
public string MessageIds { get; set; }
[JsonProperty("error")]
public string Error { get; set; }
}
I don't know why, but the property message_ids is always null!? May this be caused by the : in the string, and my this be a bug in RestSharp?
Here is what "Data" looks like:
for restsharp you need JsonPropertyName attribute
[JsonPropertyName("message_ids")]
public string MessageIds { get; set; }
or if you want to use JsonProperty you will have to use Newtonsoft.Json
var response = client.ExecuteAsync(request).Result;
//if you have async method better to use
var response = await client.ExecuteAsync(request);
Data data = JsonConvert.DeserializeObject<Data>(response.Content);