Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Salesforce by (11.9k points)

Does anyone know how to retrieve the SFDC daily requests API limit through SOAP or REST? I don't see any call for this. Currently, I have to access this info at the Company Info page. I would like to retrieve this info at the code level for batch processing.

Thanks!

1 Answer

0 votes
by (32.1k points)

Try the following code to retrieve the SFDC daily requests API limits through SOAP or REST:

WebService static string GetAPIUsage() {

    PageReference pr = new PageReference('/00D20000000HsCQ');//use id of setup page

    pr.setRedirect(false);

    String result = pr.getContent().toString();

    Integer start_index = result.indexOf('API Requests, Last 24 Hours', 1) + 52;

    Integer end_index = result.indexOf('<', start_index);

    result = result.substring(start_index, end_index);

    result = result.replaceAll('&nbsp;', ' ');

    return result;     

}

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...