2012-02-10 156 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 } }