pplication/x-www-form-urlencoded 请求格式调用
Posted wdnrsjd
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了pplication/x-www-form-urlencoded 请求格式调用相关的知识,希望对你有一定的参考价值。
public string Post(string Url, string jsonParas)
string res = string.Empty;
try
byte[] byteArray = Encoding.Default.GetBytes(jsonParas);
HttpWebRequest webReq = (HttpWebRequest)WebRequest.Create(new Uri(Url));
webReq.Method = "POST";
webReq.ContentType = "application/x-www-form-urlencoded";
webReq.ContentLength = byteArray.Length;
Stream newStream = webReq.GetRequestStream();
newStream.Write(byteArray, 0, byteArray.Length);
newStream.Close();
HttpWebResponse response = (HttpWebResponse)webReq.GetResponse();
StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
res = sr.ReadToEnd();
sr.Close();
response.Close();
newStream.Close();
catch (Exception ex)
return ex.Message;
return res;
//调用
string para = "method=AZTSSchedule&projectNo=04118180&stationIds=12331232&productId=ASZXSS";
Post("http://xxxx:8888/product/project", para);
以上是关于pplication/x-www-form-urlencoded 请求格式调用的主要内容,如果未能解决你的问题,请参考以下文章