Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/318.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 401与网络客户端https_C# - Fatal编程技术网

C# 401与网络客户端https

C# 401与网络客户端https,c#,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.Downlo

以下代码不断返回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是正确的。知道我做错了什么吗?

你试过添加代理和域吗

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

嗯,要么凭证不正确,要么你正在和一个脾气暴躁的服务器交谈。嗯,这不是凭证。