以下代码在没有代理的情况下正常工作:
System.IO.Stream feedStream = null;
System.Net.WebRequest feedClient = System.Net.WebRequest.Create(@"https://api.pinnaclesports.com/v1/feed?sportid=29&last=1414860831010&oddsformat=1¤cycode=USD");
feedClient.Proxy = new WebProxy("80.232.234.114", 8080);
string authInfo = "???:??"; // login and password here
authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo));
feedClient.Headers["Authorization"] = "Basic " + authInfo;
System.Net.WebResponse feedResp = feedClient.GetResponse();//!
feedStream = feedResp.GetResponseStream();
System.IO.StreamReader reader = new System.IO.StreamReader(feedStream, Encoding.UTF8);
String responseString = reader.ReadToEnd();
但是当使用代理时,它会给出错误:
"The remote server returned an error: (501) Not Implemented." in line '//!'
为什么呢?我尝试了另一个代理,同样的问题发生了。