我目前正在使用一个需要我以 UTF-32 编码格式发送 json 的 api。
我正在使用HttpClient
lib,但它没有像 Fiddler 那样对我的 json 进行编码,因此服务器返回错误。我已经用谷歌搜索了几个小时但没有成功,无论如何这是我的原始请求(提琴手):
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"}
编码的内容如下所示:
这是我的简单 C# 请求:
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# 的内容如下所示: