Web Service 401: Unauthorized Error

I am running a web service locally that connects to an external server that I do not have access to.

I keep getting the "401: Unauthorized" error, even though the test credentials are accurately verified by the administrators of this web service.

Do I need to configure any IIS settings?

Here is a screenshot of the error.

enter image description here

// Webservice IdentityService ws = new IdentityService(); // Test Static Credentials string username = "twfnf"; string password = "testme99"; string domain = "testapps1"; NetworkCredential credentials = new NetworkCredential(username, password, domain); CredentialCache credCache = new CredentialCache(); credCache.Add(new Uri(ws.Url), "Basic", credentials); ws.Credentials = credCache; ws.PreAuthenticate = true; ws.AuthenticateUser(); 
+4
source share
1 answer

Removing the following code using basic authentication resolves the issue.

 CredentialCache credCache = new CredentialCache(); credCache.Add(new Uri(ws.Url), "Basic", credentials); 

Final code:

  // Webservice IdentityService ws = new IdentityService(); // Test Static Credentials string username = "twfnf"; string password = "testme99"; string domain = "testapps1"; NetworkCredential credentials = new NetworkCredential(username, password, domain); ws.Credentials = credentials; ws.PreAuthenticate = true; ws.AuthenticateUser(); 
+6
source

Source: https://habr.com/ru/post/1386572/


All Articles