Эй, я никогда не работал с xml, так что простите меня за новизну, но я обычно могу нажать API и десериализовать JSON без проблем.
Этот API, однако, возвращает только XML, поэтому я не уверен что мне нужно сделать по другому?
string trendLogins = "dummpyAPIURL";
string trendArgs = "myarguments";
HttpClient client = new HttpClient();
client.BaseAddress = new Uri(trendLogins);
// Add an Accept header for XML format.
client.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/xml"));
// List data response.
HttpResponseMessage response = client.GetAsync(trendArgs).Result; // Blocking call! Program will wait here until a response is received or a timeout occurs.
if (response.IsSuccessStatusCode)
{
// Parse the response body.
var dataObjects = response.Content.ReadAsAsync<IEnumerable<AggregatedTrendData>>().Result; //Make sure to add a reference to System.Net.Http.Formatting.dll
foreach (var d in dataObjects)
{
Console.WriteLine("{0}", d.employeeID);
}
}
else
{
Console.WriteLine("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase);
}