Body is the parameter to be passed, the format "roleid=1&uid=2"
Post Cotenttype fill in:
"Application/x-www-form-urlencoded"
Soap fills in: "Text/xml; Charset=utf-8 "
public string posthttp (string url, string body, string contentType) { HttpWebRequest HttpWebRequest = (HttpWebRequest) webrequest.create (URL) ; Httpwebrequest.contenttype = contenttype; &NBS P Httpwebrequest.method = "POST"; Httpwebrequest.timeout = 20000; &nbs P byte[] Btbodys = Encoding.UTF8.GetBytes (body); Httpwebrequest.contentlength = btbodys.length; Httpwebrequest.getrequeststream (). Write (Btbodys, 0, Btbodys.length); HttpWebResponse HttpWebResponse = (Http WebResponse) HttpWebRequest.GetResponse (); StreamReader StreamReader = new StreamReader (HttpWebResponse. GetResponseStream ()); String responsecontent = Streamreader.readtoend (); httpwebresponse.close (); STREAMREADER.C Lose (); Httpwebrequest.abort (); HTTPWEBR Esponse. Close (); return responsecontent; }
C # POST request HttpWebRequest