【问题标题】:Retrieve Salesforce Daily Api Requests limit检索 Salesforce 每日 Api 请求限制
【发布时间】:2012-02-10 00:40:57
【问题描述】:

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

谢谢!

【问题讨论】:

    标签: api soap salesforce


    【解决方案1】:

    此信息未在 API 中公开。

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

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

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

    【讨论】:

    • 在客户端统计你在给定 24 小时内发出的请求数是完全不可行的吗?不是特别优雅,但听起来可能是您唯一的选择。
    • 是的,目前我们必须使用 SFDC 警报系统监控此 api 限制(例如:api 接近 80% 限制)。我希望 SFDC 在 api 中实现这样的调用,或者如果有人知道任何解决方法会很高兴从代码中检索此信息。谢谢。
    【解决方案2】:

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

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

    希望对您有所帮助。

    问候, 乌卡斯

    【讨论】:

    • 感谢您的建议 Lukasz !我会玩这个。问候,
    【解决方案3】:

    我使用了 REST API。选择要在 REST API 服务 URI 上执行的 HTTP 方法 GET:“/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 } }

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-06-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多