I'm sending an HTTP request to an endpoint, using HttpClient
class in C#.
The problem is that using Fiddler
everything works fine, but using C#, something goes wrong and I can't tell what.
Is there a way to dump HTTP request of HttpClient
instead of sending it to the server, just like how Fiddler captures traffic, so that we can see what's going on?
PCap is not my solution. I don't want to do it everywhere. I want to be able to somehow dump my single current instance of HttpClient
.
For example, let's suppose this code:
var client = new HttpClient();
// client.PostAsync(…
// client.LogPostingAsync(…
Update: (x-y problem clarification) I'm using Fiddler to test the API, and it works. Here are the parameters:
- should be POST
- Content-Type should be set to application/json
- Request body should be JSON
With the same parameters in my C# code, this piece of code causes error:
var parameters = new Parameters();
// setting properties
using (var http = new HttpClient())
{
var response = http.PostAsJsonAsync(url, parameters).Result;
// not getting the same response as Fiddler test, how to debug?
}