Unauthorized error – 401 or Log ID 5566 in Info Path form while accessing web service

Quite often, I have observed “401 – Unauthorized error” when I access any web service(GetRunningWorkflowTasksForCurrentUserForListItem, GetUserProfilebyName – I have tried with these 2 services) from my Info Path form


My form used a web service “GetRunningWorkflowTasksForCurrentUserForListItem” to get information such as task id assigned to the current user. The form was working like a charm in my development machine. But the moment it was moved to the acceptance environment, gone it was…

I can tell you I had access to this SharePoint web service. I could access the direct URL (i.e. http://SiteCollectionURL/_vti_bin/NintexWorkflow/Workflow.asmx or  http://SiteCollectionURL/_vti_bin/UserProfileService.asmx) in the browser. So why unauthorized??

Also, the error did not have any obvious pattern. Adding to my woes, it was irregular too…

This was driving me nuts…Ugh

Nevertheless, analysis led me to know that my Acceptance environment has two Web Front End Servers(WFEs), one App Server and a load balancer (the cause of my troubles here). (Unlike, my development server had one WFE and one App Server, no load balancer.)

How it all works here

So, when I load the form, my load balancer calls one of the 2 WFEs and opens up the form. However, when the web service call is made, the request is passed through the load balancer again, to one of the 2 WFEs. This is hopping twice and is known as double hop or alternate hop.


The point here was my credentials were not following an action on the 2nd hop. In this case, the first hop was from my machine to the ServerA to open the form and the 2nd hop was from ServerA through the Load Balancer to ServerB to call the web service. So my credentials were following the first server action. However, my credentials were not following the 2nd action: the web service call. Therefore, the web service call was Unauthorized and error-ed out.

Some advice from the colleagues and i got my solution… Thank God!!

The solution was to force all actions (for an instance the form is opened) to happen from one server only.

In other words, if ServerA opens the Info Path form, force other actions (say …calling the web service) to also run on ServerA. This can be done by opening ServerA’s host file and telling it to use its own IP address to open the site. So when the first action is routed through the load balancer to ServerA, any additional action will be forced to run on ServerA as well.

So I made the entries in my Host files and guess what?? My problem was solved.


7 thoughts on “Unauthorized error – 401 or Log ID 5566 in Info Path form while accessing web service

  1. Pingback: 401 Unauthorized error while calling a web service | My Learnings

  2. I am in a similar scenario. But my situation is that my infopath form loads but when I click on any tabs or buttons on the form it throws an error. Now this is inconsistent and the issue shifts from one server to another over a span of 24 hours.

    There are no issues on the Dev, QA or Stage environments and this issues is seen only on Production and Production is also a load balanced environment.

    So out of 4 wfe servers I have the form working fine on 3 and showing error on 1. This shifts randomly on various servers every 24 hours. Sometimes all servers are fine. Any tips on what I could look into to fix this?

    • Hey Varun,

      In your host header, hard code the WFE server’s name. Then close your browser and clear cache. Then check if you’re able to hit the the server. Repeat this with all four wfe.

      My assumption is it’s not shifting but the same server that is causing problem.

      Just try this and let me know. If this doesn’t helps isolate your issue, we will look forward to other ways.

    • Nicki,

      You can locate your host file here in your server – C:\Windows\System32\drivers\etc
      Open it in notepad and make an entry like below
      **.*.***.306 testSite.abc.com

      It is a mapping of the ip of your machine/server and the name of your site (where the form is hosted, just web application is sufficient).

      Then save the host file, close your browser and clear cache. Then open the site and check.

      • Thanks for your answer !
        But still ,I didn’t understand what to write in the host ,to force the form and the web service to run through the same server.

        Thanks ahead!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s