Curl不会从网站下载所有记录

时间:2019-07-27 17:35:26

标签: api pagination ringcentral

使用API​​下载公司的完整呼叫日志。该文档指出,要下载所有内容而无需分页,以列出每页记录数的列表0。这对我不起作用。我在做什么错了?

尝试0

curl --request GET \
  --url 'https://platform.ringcentral.com/restapi/v1.0/account/~/call-log?view=Simple&dateFrom=2019-07-26&dateTo=2019-07-28&page=1&perPage=0' \
  --header 'accept: application/json' \
  --header 'authorization: Bearer U0pDMDFQMTdQQVMwMHxBQUFBeHFCSjZGR3FSYkNJREcyQUlUNTUyN085b05PZEUza2R4VV9oWjF0ZzhKOUpEekJ4WDU5T2U1czFvSzJ3WGN4NF9QWWRPMEVYNENYQjd4dmJsWHJocGJRcC1BcDlrUHZIczcycTVONm13NDZJSWN6VnZ1YzNsU3NVY2doMnd2UHlCMGxkaC1MTXlfZFk5VS0yZUUtWnpRejhKUXJtT21yMFQ0ZHpKQ1AwbnhfQmRRTTRKazR3OVNuTVE4THNOa3BfcW1oX21mUGtQdWNkUVN4ZnRaUzd8Mkt2'

预期的完整通话记录。仅返回99条记录

2 个答案:

答案 0 :(得分:4)

根据此链接,"1000 is the max perPage setting. If there are more than 1000 records, you will be able to call the nextPage in a URL that's provided in the API response paging property."

https://forums.developers.ringcentral.com/questions/329/exporting-call-log-data.html

您可以尝试删除page选项
按照下面的链接,解决方案建议他们立即阅读而无需分页:

  • 阅读您帐户下的所有扩展程序。
  • 读取每个的通话记录 一次扩展一个。

ref:https://forums.developers.ringcentral.com/questions/1254/how-to-read-all-users-call-logs-at-once.html

答案 1 :(得分:0)

  

文档指出,要下载所有内容而无需分页,以列出每页记录数的列表0。

我搜索了docs,但找不到该行或任何与之特别相关的内容。

当前端点的perPage查询参数的API Spec读取以下内容:

/restapi/v1.0/account/{accountId}/call-log:
    get:
      tags:
      ...
      parameters:
      ...
        - name: perPage
          in: query
          description: Indicates the page size (number of items)
          default: 100
          required: false
          type: integer
      ...

尽管通过查看one of the examples provided,我假设要获取最大日志perPage应当设置为1000,并且不应将page作为以下功能提供建议:

function readCallLogs(){
  var configs = {}
  if ($('#phoneNumber').val() != "")
    configs['phoneNumber'] = $('#phoneNumber').val()
  if ($('#extension').val() != "")
    configs['extensionNumber'] = $('#extension').val()

  if ($('#direction').val() != "default")
    configs['direction'] = $('#direction').val()
  if ($('#type').val() != "default")
    configs['type'] = $('#type').val()
  if ($('#transport').val() != "default")
    configs['transport'] = $('#transport').val()

  configs['view'] = $('#view').val()

  configs['showBlocked'] = $('#showBlocked').is(":checked")
  configs['withRecording'] = $('#withRecording').is(":checked")
  configs['dateFrom'] = $("#fromdatepicker").val() + "T00:00:00.000Z"
  configs['dateTo'] = $("#todatepicker").val() + "T23:59:59.999Z"
  configs['perPage'] = 1000

  var url = "readlogs?access=" + $('#access_level').val();
  var posting = $.post( url, configs );
  posting.done(function( response ) {
    var res = JSON.parse(response)
    if (res.hasOwnProperty('calllog_error')){
      alert(res.calllog_error)
    }else{
      callLogsData = new CallLogsData(JSON.parse(response))
      drawGraphs()
    }
  });
  posting.fail(function(response){
    alert(response.statusText);
  });
}

因此,您应该尝试编辑初始呼叫以匹配以下内容:

GET /restapi/v1.0/account/~/call-log?view=Simple&dateFrom=2019-07-26&dateTo=2019-07-28&perPage=1000 HTTP/1.1
Host: platform.devtest.ringcentral.com
Accept: application/json
Authorization: Bearer U0pDMDFQMTdQQVMwMHxBQUFBeHFCSjZGR3FSYkNJREcyQUlUNTUyN085b05PZEUza2R4VV9oWjF0ZzhKOUpEekJ4WDU5T2U1czFvSzJ3WGN4NF9QWWRPMEVYNENYQjd4dmJsWHJocGJRcC1BcDlrUHZIczcycTVONm13NDZJSWN6VnZ1YzNsU3NVY2doMnd2UHlCMGxkaC1MTXlfZFk5VS0yZUUtWnpRejhKUXJtT21yMFQ0ZHpKQ1AwbnhfQmRRTTRKazR3OVNuTVE4THNOa3BfcW1oX21mUGtQdWNkUVN4ZnRaUzd8Mkt2