1

How does the API count increase when i use a REST API. I have a REST API apex class to insert records into a custom object, and I am trying to figure out how many API calls it takes to process one record creation request .

I was using the a coarse grained request through workbench for the following apex class- I see that my API count increases by more than one.

@RestResource(urlMapping='/MultiEvent/*')
global with sharing class MultiEventRestController{
 global class RequestBody {
   global List<Event__c> events;
 }

@HttpPost   
global static List<Event__c> createBulk(MultiEventRestController.RequestBody req) {
    insert req.events; 
    return req.events;
}
}
2
  • How are you monitoring the API count, how do you know nothing else is making API calls to your org? how many does it go up by?
    – superfell
    Oct 7, 2015 at 19:56
  • I am the only one making calls to the org- it was created for testing.
    – goSF
    Oct 12, 2015 at 12:35

1 Answer 1

3

All REST calls use exactly one call. Custom REST classes and RemoteAction methods may incur usage (e.g. Sites page views) when used in certain contexts, but they will never consume more than 1 call per use.

4
  • Yes, that's still just one API call. Since the REST API doesn't have native bulk operations, many developers use code like this to reduce API usage.
    – sfdcfox
    Oct 7, 2015 at 19:36
  • but I can still see that the count of the API call is more than 1.
    – goSF
    Oct 7, 2015 at 19:38
  • @user25303 Using the workbench may cause additional calls simply by the nature of it doing things. Also, the limit is "laggy", it runs a few seconds behind the actual metered value. Trust me, it really does use just one at a time. You'd need to use a tool that doesn't otherwise use API calls, like a REST client, and make sure you don't do anything else for a few seconds before and after getting the API limit value, just to validate that you're getting the correct results.
    – sfdcfox
    Oct 7, 2015 at 20:04
  • Thank you. But I was confused because an request to insert a single record from workbench only took 1 API call while a course grained request (insert multiple records) takes 4 API calls regardless of the number of records. I monitored this when my API counter for the day was 0 and including all lags. Is this expected?
    – goSF
    Oct 13, 2015 at 19:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .