7

Environment: SharePoint 2013 Online & InfoPath form 2013

I'm try to make a data collection using REST API and using a button to trigger the action.

When I preview the form & press the button first time, I get the error as below

The query cannot be run for the following DataObject: Document in Dev InfoPath cannot run the specified query.
The file is not a valid XML file.
Some form data cannot be retrieved bacause InfoPath is operating offline mode. Form elements, such as drop-down lists, may be blank. Ensure that you have network connectivity and that InfoPath is online mode.


When I Click the button second time , it can be receive the data.

When I publish the form to SharePoint, I will get the error every time when i press the button

XML data that is required for this form to function correctly cannot be found.
An entry has been added to the Windows event log of the server.
Log ID:5566


Any Idea??
I can get the correct data when I directly access the REST API link.

Eric Herlitz
  • 25,354
  • 27
  • 113
  • 157
HateBear
  • 91
  • 1
  • 2
  • 8

2 Answers2

1

You must add ?NoRedirect=true when downloading the file

file.xml?NoRedirect=true
Eric Herlitz
  • 25,354
  • 27
  • 113
  • 157
  • did you mean update the REST URL from../_api/web/lists/GetByTitle('hkbnFormLibrary')/items to ../_api/web/lists/GetByTitle('hkbnFormLibrary')/items?NoRedirect=true ?? If Yes , this solution is not work for me. – HateBear Mar 25 '14 at 02:39
  • No, to the actual file you are downloading. How do you call it? – Eric Herlitz Mar 25 '14 at 09:16
  • e.g.REST Call URL: https:// siteurl/_api/web/lists/GetByTitle('TestingDocuments')/items?$orderby=FormID%20desc&$top=1 – HateBear Mar 26 '14 at 04:05
  • using the InfoPath Data Collection function, create a REST Web service and using this url https:// siteurl/_api/web/lists/GetByTitle('TestingDocuments')/items?$orderby=FormID%20desc&$top=1 – HateBear Mar 26 '14 at 04:14
  • Hi guys, any luck how to call rest api using infopath 2013 – Light Sep 25 '19 at 11:00
0

Same error (400 bad request) cost me much time. My working solution is adding NoRedirect=true at the end of my URL:

http://server/qa/_vti_bin/owssvr.dll?Cmd=Display&List={***E885}&XMLDATA=TRUE&noredirect=true

Ref: https://sajiviswam.wordpress.com/2012/03/20/the-form-cannot-run-the-specified-query-in-infopath-2007-forms-migrated-to-sharepoint-2010/#comment-564

Floern
  • 33,559
  • 24
  • 104
  • 119
Kevin .NET
  • 463
  • 6
  • 9