Webservices: “The request failed with HTTP status 401: Access Denied.”

I received this error recently when trying to setup web service authentication. This error shows up when anonymous authentication is not setup on IIS. To fix this error, follow the steps below.

1) Internet Information Services control panel
2) Right click your web site and select Properties
3) Select the Directory Security tab
4) Click the Edit button
5) Check off the Anonymous access checkbox
6) Click OK
7) Click Apply and OK.

Another option is to code it directly into your code. You can do this by using the credential cache.

C#
Service MyService = new Service();
MyService.PreAuthenticate = true;
MyService.Credentials = System.Net.CredentialCache.DefaultCredentials;

By passing the credentials into the service will allow the anonymous access to the service.

One Response to "Webservices: “The request failed with HTTP status 401: Access Denied.”"

  1. Thanks for update, it help a lot to our development team. We were also facing the same problem for some time.

Leave a Reply