question

Raymond Camden avatar image
Raymond Camden asked Phong Vu commented

Paging with Call Log

I'm trying to work with the call log API and ensure I retrieve all the possible data. According to the docs, the result has a paging object that MAY return totalPages or totalElements. In all of my calls to the call log, I never see these values. Given that, how do I know when to stop fetching data?

To test I tried to paginate 2 items at a time. My call log has 4 items in it so I figured this would let me test fetching two pages. On the first request, the paging result has pageStart of 0, which means the first record is index 0. I then fetch my next page, the same. My code then fetches a third page, which is wrong of course, and I see pageStart now has a value of 2, which doesn't make sense as it should be an array of 2 values.

So *in theory*, I could say if pageStart > what my page max should be (well using 0 based indexes) then it means to stop, but is that right?


rest api
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Phong Vu avatar image
Phong Vu answered

Just a quick answer, I recommend you to use the navigation object to navigate thru reading your call log.


1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Raymond Camden avatar image
Raymond Camden answered Phong Vu commented

This was meant to be a comment on the last user's response, but comments have a max set of chars.

I tried that, but in my testing the URLs didn't make sense. Consider - this is the result I get after fetching my second page, which is the last:


navigation {
  nextPage: {
    uri: 'https://platform.devtest.ringcentral.com/restapi/v1.0/account/272299004/extension/272299004/call-log?view=Detailed&direction=Inbound&showBlocked=true&withRecording=false&dateFrom=2020-01-01T00:00:00.000Z&page=3&perPage=2'
  },
  previousPage: {
    uri: 'https://platform.devtest.ringcentral.com/restapi/v1.0/account/272299004/extension/272299004/call-log?view=Detailed&direction=Inbound&showBlocked=true&withRecording=false&dateFrom=2020-01-01T00:00:00.000Z&page=1&perPage=2'
  },
  firstPage: {
    uri: 'https://platform.devtest.ringcentral.com/restapi/v1.0/account/272299004/extension/272299004/call-log?view=Detailed&direction=Inbound&showBlocked=true&withRecording=false&dateFrom=2020-01-01T00:00:00.000Z&page=1&perPage=2'
  },
  lastPage: {
    uri: 'https://platform.devtest.ringcentral.com/restapi/v1.0/account/272299004/extension/272299004/call-log?view=Detailed&direction=Inbound&showBlocked=true&withRecording=false&dateFrom=2020-01-01T00:00:00.000Z&page=1&perPage=2'
  }
}

Notice how firstPage and lastPage have, as far as I can see, the exact same URL. nextPage doesn't indicate it won't return anything.

Here's what I get after fetching my first page.

navigation {
  nextPage: {
    uri: 'https://platform.devtest.ringcentral.com/restapi/v1.0/account/272299004/extension/272299004/call-log?view=Detailed&direction=Inbound&showBlocked=true&withRecording=false&dateFrom=2020-01-01T00:00:00.000Z&page=2&perPage=2'
  },
  firstPage: {
    uri: 'https://platform.devtest.ringcentral.com/restapi/v1.0/account/272299004/extension/272299004/call-log?view=Detailed&direction=Inbound&showBlocked=true&withRecording=false&dateFrom=2020-01-01T00:00:00.000Z&page=1&perPage=2'
  },
  lastPage: {
    uri: 'https://platform.devtest.ringcentral.com/restapi/v1.0/account/272299004/extension/272299004/call-log?view=Detailed&direction=Inbound&showBlocked=true&withRecording=false&dateFrom=2020-01-01T00:00:00.000Z&page=1&perPage=2'
  }
}

In this case, nextPage would work, but lastPage is the same as firstPage again.

1 comment
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Phong Vu avatar image Phong Vu ♦♦ commented ·

I think because you did not specify the "dateTo" in your query so the system will keep the "nextPage" open because there maybe new call log coming. Can you try with the "dateTo" to see if it is the same.

"lastPage" should not be returned at all but for some reason, it is still returned. It might relate to the "dateTo" param as well.

0 Likes 0 ·

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys