.net httpclient Charset encoding is different than Fiddler

220 views Asked by At

I'm currently working with an api that requires me to send a json in UTF-32 encoding format.

I am using HttpClient lib but it does not encode my json the way Fiddler does so the server returns error. I've googled for hours but without success, anyway here's my raw request (Fiddler):

POST http://example.com/ HTTP/1.1
Content-Type: application/json; charset=utf-32
Host: example.com
Content-Length: 92
Expect: 100-continue
Connection: Keep-Alive

{"jsonKey":"JsonValue"}

The encoded content looks like this:

enter image description here

and here's my simple C# request:

using(HttpClient client = new HttpClient(new HttpClientHandler() { Proxy = new WebProxy("127.0.0.1:8080") }))
{
    _ = await client.PostAsync("http://example.com", new StringContent("{\"jsonKey\":\"JsonValue\"}", Encoding.UTF32, "application/json")).ConfigureAwait(false);
}

C#'s content looks like this:

enter image description here

0

There are 0 answers