This seems to be a known limitation of InfoPath forms because Loopback protection is always enabled in SharePoint Online. Due to this, you cannot create data connection to some of the sharepoint services/methods. In order to make it happen, this Loopback protection must be disabled for InfoPath forms to be able to connect to some SharePoint Online Web Services. But as confirmed by Microsoft. it is not possible to disable it due to security issue.
The issue is that InfoPath form instances in a SharePoint form library throw an error when we have a data connection to some of the SharePoint services. For example:
- An internally accessed SharePoint asmx legacy web service.
- An internally accessed SharePoint REST service.
The issue is caused by unpublished information related to the DvN environment. In order for a data connection to work, the url to the data connection cannot be an internal SharePoint online connection, except in a few exceptional cases as describe below. The two conditions for accessing urls that serves as data connections are the following:
- It must be a url that is accessible via public DNS.
- It must be an https accessible url that has a public certificate.
For more details and supported services methods, access the URL.
Note: This workaround has not been published by Microsoft, one of my client Architect has shared this information after discussing with Microsoft.