One way to overcome “429” error (concurrent requests limit exceeded error) in Dynamics 365 CRM Web API

By | April 22, 2019

Introduction

With JavaScript, we have real-time interaction with Dynamics 365. Microsoft gives us feasibility to use CRM Web API in JavaScript to perform operations such as Create, Update, Delete, Retrieve, etc.

But there is a limitation on the number of API requests made by each user, per organization instance, within a five-minute sliding window. Please refer the below blog for more details:

https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/api-limits

This limit will cause the issue to the organization which is using a large number of requests for their application.

The application will throw “429” error which will give this type of message: “Combined execution time of incoming requests exceeded limit of 1,200,000 milliseconds over a time window of 300 seconds. Decrease the number of concurrent requests or reduce the duration of requests and try again later.”

Solution

To overcome this error, we have used JavaScript’s setTimeout() function. setTimeout() for single request works as expected but in order to use setTimeout() in for loop you need to add extra piece of code to get a proper result i.e. by using setTimeout() with IIFE (Immediately Invoked Function Expression).

var waitInterval = 300;

for (var i = 0; i < result.List.length; i++) {

(function (i) {

setTimeout(function () {

crmAPI.Create(entityName, record).then(function success(result){

});

}, waitInterval * i);

})(i);

}

You can change the waiting interval based on number of requests.

Conclusion

By using JavaScript’s setTimeout() with IIFE (Immediately Invoked Function Expression) we can overcome the CRM API limit.

2 thoughts on “One way to overcome “429” error (concurrent requests limit exceeded error) in Dynamics 365 CRM Web API

  1. Ivo

    Hi,

    I have no idea how to implement this in my Power Automate. Do I simply add a Javascript action in my flow? Or do I have to manually add a TimeOut as well?

    Thanks!

    Ivo

    Reply
    1. Inogic Post author

      We cannot add javascript function in Power Automate.

      Instead, we can use the ‘Retry Policy’ option in Power Automate. Follow the steps given below to apply Retry Policy in Flow.

      • Click on the ellipses (…) on the right-hand side corner of the action:

      Power-Automate

      • In Setting page, you can see that “Retry Policy” option, as shown below,

      Power-Automate

      In the Retry Policy setting, you can select any of the following types,

      Power Automate

      Hope this helps.

      Thanks!

      Reply

Leave a Reply

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