Hi Paul,
Could you us some guidance on how to debug when an api call doesn't return the expected result? For example, when I do an api call, I get back null instead of a User object. When I drill into the methods being executed, I would like to end up somewhere so that I can see the response (content) to get some indication of why I got null.
Would it be nice to add some debugging lines for each request/response? Like status, headers, content, etc
I've created this logging mechanism myself...
Don't know it this is the way to go, but I can now get some logging going...
public class LoggingMessageHandler : DelegatingHandler
{
public LoggingMessageHandler(HttpMessageHandler innerHandler)
: base(innerHandler)
{
}
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
Debug.WriteLine("Request:");
Debug.WriteLine(request.ToString());
if (request.Content != null)
{
Debug.WriteLine(await request.Content.ReadAsStringAsync());
}
var response = await base.SendAsync(request, cancellationToken);
Debug.WriteLine("Response:");
Debug.WriteLine(response.ToString());
if (response.Content != null)
{
Debug.WriteLine(await response.Content.ReadAsStringAsync());
}
return response;
}
}
@promontis I would start by setting up something like Runscope to see what the response content is, and see if that deserializes to the object you want (you can also change the return type to string to just see it as text)
Most helpful comment
I've created this logging mechanism myself...
Don't know it this is the way to go, but I can now get some logging going...