401与webclient https

时间:2012-03-20 13:37:24

标签: c#

以下代码不断返回401:

        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));

在最后一行。密码和网址是正确的。知道我做错了吗?

1 个答案:

答案 0 :(得分:0)

您是否尝试过添加代理和域名?

WebClient client = new WebClient();
client.Proxy = new WebProxy("<<your proxy here>>");
client.Proxy.Credentials = new NetworkCredential("login", "password", "domain");