You can
- Use proxy to debug traffic
- Use API testing tool
- Modify your code to log requests/responses
First option - proxy. Take a look on Fiddler. It shows you request/response data and allows to see https data too. As @Balazs noted, with Fiddler you can compose, capture, edit and send requests as well.
Second option - API testing tool. There are lot of them (SoapUI, RESTClient etc), but I suggest to take a look on Postman. It allows touching your API both manually and automatically via tests.
Last option is up to you. E.g. you can create OWIN Middleware, which will log request and/or response.
UPDATE: Seems like you want to log requests on client side instead of server side. So instead of OWIN Middleware you can create custom message handler:
public class LoggingHandler : HttpClientHandler
{
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
protected override Task<HttpResponseMessage> SendAsync(
HttpRequestMessage request, CancellationToken cancellationToken)
{
// log request or its part here
Logger.Trace(request.ToString());
return base.SendAsync(request, cancellationToken);
}
}
And pass it to HttpClient
:
var client = new HttpClient(new LoggingHandler());
client.DefaultRequestHeaders.Add("Accept", "application/xml");
var response = await client.GetStringAsync("http://localhost:12345/api/blah");