2012-02-10 154 views
5

有谁知道如何通过SOAP或REST检索SFDC每日请求api限制吗?我没有看到任何呼吁。目前,我必须在公司信息页面访问此信息。我想在代码级检索这些信息进行批处理。检索Salesforce每日Api请求限制

谢谢!

回答

3

我们正在使用自定义代码来解决此:

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;  
} 

希望有所帮助。

问候, 卢卡斯

+0

感谢您的建议Lukasz!我会玩这个。 关心, – 2012-02-21 22:23:43

4

此信息未在API中公开。

从Salesforce Spring '15和REST API版本29.0开始,/ limits资源可用于检索此信息。 https://developer.salesforce.com/releases/release/Spring15/restapi

此外,Sforce-Limit-Info标头会随每个REST响应一起返回。

https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/headers_api_usage.htm

+2

它是完全不可行的计算您在客户端上的一个给定的24小时内提出请求的数量?不是特别优雅,但听起来可能是您唯一的选择。 – 2012-02-10 05:24:18

+0

是啊,目前我们必须使用SFDC警报系统来监控此api限制(例如:api接近80%限制)。我希望SFDC在API中实现这样的调用,或者如果有人知道任何解决方法将很好从代码中检索此信息。谢谢。 – 2012-02-14 17:13:40

1

我使用REST API。选择一个HTTP方法GET在REST API服务URI上执行:“/services/data/v31.0/limits”。它允许我获取DailyApiRequests数据。

它返回:

{ "ConcurrentAsyncGetReportInstances" : { "Remaining" : 200, "Max" : 200 }, "ConcurrentSyncReportRuns" : { "Remaining" : 20, "Max" : 20 }, "DailyApiRequests" : { "Remaining" : 14995, "Max" : 15000 }, "DailyAsyncApexExecutions" : { "Remaining" : 250000, "Max" : 250000 }, "DailyBulkApiRequests" : { "Remaining" : 5000, "Max" : 5000 }, "DailyStreamingApiEvents" : { "Remaining" : 10000, "Max" : 10000 }, "DailyWorkflowEmails" : { "Remaining" : 390, "Max" : 390 }, "DataStorageMB" : { "Remaining" : 5, "Max" : 5 }, "FileStorageMB" : { "Remaining" : 20, "Max" : 20 }, "HourlyAsyncReportRuns" : { "Remaining" : 1200, "Max" : 1200 }, "HourlyDashboardRefreshes" : { "Remaining" : 200, "Max" : 200 }, "HourlyDashboardResults" : { "Remaining" : 5000, "Max" : 5000 }, "HourlyDashboardStatuses" : { "Remaining" : 999999999, "Max" : 999999999 }, "HourlySyncReportRuns" : { "Remaining" : 500, "Max" : 500 }, "HourlyTimeBasedWorkflow" : { "Remaining" : 50, "Max" : 50 }, "MassEmail" : { "Remaining" : 10, "Max" : 10 }, "SingleEmail" : { "Remaining" : 15, "Max" : 15 }, "StreamingApiConcurrentClients" : { "Remaining" : 20, "Max" : 20 } }