An Alternative Approach to Query User Profile Service in InfoPath using SharePoint Online

Background

In InfoPath form, to auto populate user details, generally we, SharePoint Developers, used the GetUserProfileByName method by creating a data connection to https://tahmidulabedin.me/_vti_bin/userprofileservice.asmx?WSDL. And we used to be using this in SharePoint on-premises. Few days ago, I was trying to create an InfoPath form in SharePoint Online with Office 365 and I got an error as “An error occurred while connecting to a Web Service“.

After searching on the internet, I found that Microsoft has purposefully disabled access to the User Profile service to Prevent Loop Back issues. As per Microsoft support, to call UserProfileService web service, data security authentication is required before the service will return any data. And the method, GetUserProfileByName of SharePoint UserProfileService makes the call anonymously, which is the convention for all web calls. As anonymous access is not allowed in the web application, the SharePoint server returns an authentication error (code 401).

Using the Step

I had to overcome this issue and I found one. To create a Data Connection for populating common user fields, using “User Information List” hidden list is the best approach. To create a data collection with this list, you need to follow the usual approach of creating data connection in InfoPath and select SharePoint List or Library as data source.

The hidden list will be shown with other Sharepoint lists. And by selecting this, you will get many user attributes which can be pulled as required.

Points of Interest

If anyone knows of any better approach, please let me know in the comments below and I will update my tip.

Leave a Reply

%d bloggers like this: