public string Get (string uri)
{
//according to customer request uri structure first address
String serviceUrl=the string. Format (" {0}/{1} ", enclosing BaseUri, uri);
//create the Web access to like
HttpWebRequest myRequest=(HttpWebRequest) WebRequest. Create (serviceUrl);
//through the Web access object to obtain response content
HttpWebResponse myResponse=(HttpWebResponse) myRequest. The method GetResponse ();
//create StreamReader object through the response content flow, because StreamReader more advanced faster
StreamReader reader=new StreamReader (myResponse GetResponseStream (), Encoding, UTF8);
//string returnXml=HttpUtility. UrlDecode (reader. ReadToEnd ());//if a coding problem in this way
String returnXml=reader. ReadToEnd ();//use of StreamReader can be read from the response content
Reader. The Close ();
MyResponse. Close ();
Return returnXml;
}
CodePudding user response:
Access denied.Do you want to check the interface permissions, or write access, and so on questions,
https://www.cnblogs.com/jiaoaozuoziji/p/7283322.html
CodePudding user response:
What to see there are verified, increase the user-agent tryHttpWebRequest myRequest=(HttpWebRequest) WebRequest. Create (serviceUrl);
myRequest. UserAgent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; The.net CLR 1.1.4322; The.net CLR 2.0.50727) ";
CodePudding user response: