httpclient POST请求(urlencoded)

it2022-07-01  91

搬砖搬砖~ Content-Type:application/x-www-form-urlencoded的请求如下

var nvc = new List<KeyValuePair<string, string>>(); nvc.Add(new KeyValuePair<string, string>("account", "")); nvc.Add(new KeyValuePair<string, string>("password", "")); var client = new HttpClient(); var req = new HttpRequestMessage(HttpMethod.Post, url) { Content = new FormUrlEncodedContent(nvc) }; var res = await client.SendAsync(req); var s=await res.Content.ReadAsStringAsync();

参考资料

https://stackoverflow.com/questions/43158250/how-to-post-using-httpclient-content-type-application-x-www-form-urlencoded

转载于:https://www.cnblogs.com/Lulus/p/9012837.html

相关资源:数据结构—成绩单生成器

最新回复(0)