Use WEB API Batch Request in Dynamics 365 to execute long FetchXML

By | July 27, 2018

Introduction:

Recently we had a project where we use WEB API for retrieve the records from Dynamics CRM. In our project, we dynamically create FetchXML to retrieve records but sometimes Fetchxml have a lot of columns and conditions etc so its length get increase and we this the fetchxml in URL which violates the browser URL length rule. So When we try to execute this long length FetchXML and retrieve the records using the GET method, We were getting the error message of “HTTP Error 404 – Not Found” because of WEB API request fails to execute too long FetchXML. When we work on this error message, we find that we need to use WEB API Batch Request to execute the long FetchXML.

In the below example, we execute the long FetchXML of account entity and use POST request to execute long FetchXML.

First, we created the simple request body as below:

Note: ‘fetch’ is the parameter of the long FetchXML.

And we pass the created the simple request body as data to Ajax request and we will receive the response of request as success or failure as below:

Conclusion:

User can easily execute the long length FetchXML using the WEB API Batch Request.

To read more about FetchXML visit here.

Export Dynamics CRM Reports

Leave a Reply

Your email address will not be published. Required fields are marked *