身份验证的HttpClient返回404.为什么?

时间:2015-08-31 12:49:48

标签: c# rest http windows-8.1 httpclient

我有一个需要使用用户名和密码进行身份验证的API。我无法弄清楚为什么我的代码失败并且响应是404,当我正在执行GET方法并提供实际凭据时:

NetworkCredential networkCredentials = new System.Net.NetworkCredential("adminUN", "mypassword");
HttpClientHandler handler = new HttpClientHandler();
handler.PreAuthenticate = true;
handler.Credentials = networkCredentials;

httpClient = new HttpClient(handler);

HttpResponseMessage response = await httpClient.GetAsync(GlobalDeclarations.strURL);

0 个答案:

没有答案