Asp.net core 在应用程序/x-www-form-urlclient中传递数据 将来自邮递员的数据作为x-www-form-urlencoded传递 键和值如下所示: 数据:P1;P2 格式:json
来自邮递员的对应curl代码 curl --location --request POST 'https://ap-url/id/' \ --header 'content-type: application/x-www-form-urlencoded' \ --data-urlencode 'data=P1;P2' \ curl--location--request POST'https://ap-url/id/' \ --标题“内容类型:应用程序/x-www-form-urlencoded”\ --数据urlencode'数据=P1;P2'\ 如何在HttpClient上以x-www-form-urlencoded的形式发送数据Asp.net core 在应用程序/x-www-form-urlclient中传递数据 将来自邮递员的数据作为x-www-form-urlencoded传递 键和值如下所示: 数据:P1;P2 格式:json,asp.net-core,httpclient,x-www-form-urlencoded,Asp.net Core,Httpclient,X Www Form Urlencoded,来自邮递员的对应curl代码 curl --location --request POST 'https://ap-url/id/' \ --header 'content-type: application/x-www-form-urlencoded' \ --data-urlencode 'data=P1;P2' \ curl--location--request POST'https://ap-url/id/' \ --标题“内容类型:应用程序/x-www-form-urlencoded”
使用(var httpClient=new httpClient())
{
使用(var request=newhttprequestmessage(newhttpmethod(“POST”),”https://api-url/id"))
{
var contentList=新列表();
Add($”数据={Uri.EscapeDataString(“P1;P2”)});
Add($”格式={Uri.EscapeDataString(“json”)});
request.Content=newstringcontent(string.Join(&),contentList));
request.Content.Headers.ContentType=MediaTypeHeaderValue.Parse(“application/x-www-form-urlencoded”);
var response=wait httpClient.sendaync(请求);
}
}
curl --location --request POST 'https://ap-url/id/' \
--header 'content-type: application/x-www-form-urlencoded' \
--data-urlencode 'data=P1;P2' \