function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Pari M 28Pari M 28 

Control the number of API requests that I can make from Salesforce to avoid the rate limit error

I would like to make multiple API requests from Salesforce to a 3rd party.
I can make only 50 requests/ minute.
As there are thousands of records, I am using a batch to achieve this. However, how can I make sure that my batch doesn't exceed 50 requests/ min. If I don't have this limit in place, I would encounter rate limit error (from the third party)

As I haven't found a delay/ timer function that I coud use, any examples or ideas are appreciated.
Thanks
Abdul KhatriAbdul Khatri
Please user Queueable Apex for the Callouts to 3rd Party. The benefit of this you can do the chain of Jobs. You may need to create two classes that does the same and call them alternatively once one reached the limit of Callouts.

https://trailhead.salesforce.com/en/modules/asynchronous_apex/units/async_apex_queueable

I hope this help you cause
Raj VakatiRaj Vakati

You can do one thing .. .


Create a custom filed on object ( processed__c with data type boolean ) 

Once you process the data using Queueable Apex  you can mark as Processed to true and implement chaining ..