401与网络客户端https

本文关键字:https 客户端 网络 | 更新日期: 2023-09-27 18:28:35

以下代码不断返回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));

在最后一行。密码和url正确。知道我做错了什么吗?

401与网络客户端https

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

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