401与Web客户端HTTPS
问题描述:
下面的代码保存返回401:401与Web客户端HTTPS
String URI = "https://api.opsourcecloud.net/oec/0.9/myaccount";
WebClient webClient = new WebClient();
webClient.Credentials = new NetworkCredential("username", "password");
string s = webClient.DownloadString(URI);
StreamReader reader = new StreamReader(webClient.OpenRead(URI));
在最后一行。密码和网址是正确的。任何想法我做错了什么?
答
您是否尝试添加代理和域名?
WebClient client = new WebClient();
client.Proxy = new WebProxy("<<your proxy here>>");
client.Proxy.Credentials = new NetworkCredential("login", "password", "domain");
那么,无论是凭证是不是正确的,或者你正在谈论一个_very_脾气暴躁的服务器。 – cdeszaq 2012-03-20 13:45:24
嗯,这不是凭证。 – dotnetdev 2012-03-22 15:14:01