I have a server that sends back this xml:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<DataRequestResponse>
<Reports>
<ReportBlocks>
<RowDates>2014-08-01</RowDates>
<RowDates>2014-08-04</RowDates>
<RowDates>2014-08-05</RowDates>
<Values>3.79</Values>
<Values>3.798</Values>
<Values>3.79</Values>
</ReportBlocks>
</Reports>
</DataRequestResponse>
I made these C# classes:
public class DataRequestResponse{
public List<Reports> Reports { get; set; }
}
public class Reports{
public List<ReportBlocks> ReportBlocks { get; set; }
}
public class ReportBlocks{
public List<string> RowDates { get; set; }
public List<string> Values { get; set; }
}
Then I run the web service query with:
var client = new RestClient("https://example.com");
var request = new RestRequest ("the/api", Method.POST);
string query = "<q>whatever</q>";
request.AddParameter("application/xml", query, ParameterType.RequestBody);
var response = client.Execute<DataRequestResponse>(request);
response.Content is correct. However when I look at response.Data I have one entry in Reports but the ReportBlocks inside it is an empty list.
Where could I be going wrong?
I have RestSharp working nicely for another part of this API, which actually felt like the more complex XML, so I am a bit stumped why it is not working here.
(I have elided the attributes, and some other child XML elements, from the above XML example; but my other tests have shown that RestSharp happily ignores the attributes and nodes you are not interested in.)
No comments:
Post a Comment