我有一个需要使用用户名和密码进行身份验证的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);