Windows phone 8.1 POST x-www-form-urlencoded无法工作

本文关键字:工作 x-www-form-urlencoded POST phone Windows | 更新日期: 2023-09-27 18:24:05

我正试图在C#中发送POST x-www-form-urlencoded请求payway支付api。

这是我的代码:

HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, new Uri(url));
List<KeyValuePair<string, string>> bla = new List<KeyValuePair<string, string>>();
bla.Add(new KeyValuePair<string, string>("id_number","2000"));
request.Content = new HttpStringContent(new HttpFormUrlEncodedContent(bla).ToString(),Windows.Storage.Streams.UnicodeEncoding.Utf8, "application/x-www-form-urlencoded");

Api向我返回状态代码100,表示"错误的id_number"。

我还试着通过Postman发送POST,效果很好。

POST /services/test HTTP/1.1
Host: example.tk
Cache-Control: no-cache
Postman-Token: c67b2ee3-6e25-7ecc-61f5-38282c23sds7d
Content-Type: application/x-www-form-urlencoded
id_number=2000

有人知道我错过了什么吗?

Windows phone 8.1 POST x-www-form-urlencoded无法工作

使用NavigateToString(")并在里面添加html表单并发布:D