我知道我可以发送 json 但我找不到如何发送 x-www-form-urlencoded。我不知道该尝试什么,因为我找不到任何东西。
WebClient wc = new WebClient();
string data = "channel_id=+12039273888&channel_type=phone&channel_verification=514950";
wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
string result = wc.UploadString("http://3.86.171.88/api/login", data);
System.Console.WriteLine(result);
您可以UploadString()
在WebClient
类上使用方法,例如
string data = "name=john&age=20&city=Uganda";
using (WebClient client = new WebClient())
{
client.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
string result = client.UploadString(url of api resource, data);
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句