According to the documentation, the Salesforce REST API returns a
Limit Info Headerwith each request. So each REST API call gets a
Sforce-Limit-Info: api-usage=18/5000line returned in the response header.
When I make a call to a custom Apex REST API endpoint, this header is not automatically included in the response. The only other way I can find to programmatically determine the limit for an organization is to ping the
/limitsREST endpoint. But, according to a SF employee:
This feature is still in pilot mode, and just “might” become generally
available with the winter 15 release (november).
Sforce-Limit-Infoisn’t being returned in the header, and
/limitsendpoint isn’t in production yet, how can my custom APEX REST endpoint programmatically determine the limits for the authorized organization today, and, how many requests have been made towards those limits?
It doesn’t solve the issue, but what would be great/helpful is if Salesforce added a
daily_limitreturn parameter to the OAuth connection so you at least know the organizations max daily usage at the time you authorize them.
Well, you could make a Force.com REST call after your custom call. Something like a trivial select. This is not an efficient solution. It will increase the speed at which you use up calls and will slow down whatever is consuming this info as it now needs to call your custom endpoint, then this trivial one as well. I will continue to research since this is a bucket of nope but it does get you the information you are looking for.