ServicePointManager. ServerCertificateValidationCallback +=RemoteCertificateValidate;
ServicePointManager. SecurityProtocol=SecurityProtocolType. Tls;
Encoding Encoding.=Encoding UTF8;
HttpWebRequest request=(HttpWebRequest) WebRequest. Create (url);
Request. The Method="POST";
Request. Accept="application/json, text/javascript, */*; Q=0.01 ";
//request. ContentType="application/x - WWW - form - urlencoded; Charset=utf-8 ";
Request. ContentType="application/json";
Byte [] buffer=encoding. GetBytes (body);
Request. ContentLength=buffer. Length;
Request. GetRequestStream (.) Write (buffer, 0, buffer. Length);
HttpWebResponse response=(HttpWebResponse) request. The method GetResponse ();
//HttpWebResponse response=request. The method GetResponse () as HttpWebResponse;
Using (StreamReader reader=new StreamReader (response. GetResponseStream (), Encoding, UTF8))
{
HttpStatusCode cc=response. StatusCode;
Console. WriteLine (" HttpStatusCode -- -- -- -- -- -- -- -- -- -- "+ cc. The ToString ());
Return reader. ReadToEnd ();
}
In this code: HttpWebResponse response=(HttpWebResponse) request. The method GetResponse ();
Error: System.Net.WebException: "remote server returns an error: (500) internal server error"
Survey didn't understand, one day, for help
CodePudding user response:
https://www.cnblogs.com/gygang/p/8950143.html
https://blog.csdn.net/cdb104/article/details/80507580
Give you two reference
500 could be the server, it is possible that the parameter problem