Zack_Turnbow | 2020-09-23 20:54:53 UTC | #1
When using GET /api/v2/externalcontacts/scan/contacts, how will I know I'm at the end? Will the nexUri and the cursors be empty?
Jerome.Saint-Marc | 2020-09-24 07:39:16 UTC | #2
Hello,
You can indeed rely on the cursors (and I assume nextUri as well - I prefer cursors but this is just my own choice as you are allowed to change the limit parameter value on the next request if you want). If it is the end (no more data to retrieve), you will still have a "cursors" attribute but with value {} [and no nextUri attribute]
{ .... "cursors":{} }
Otherwise, it contains an "after" attribute. I mean:
{ .... "cursors":{ "after": "........." } }
As a side comment, when you retrieve the last "page" (I mean the last set of data - reaching the end of the contacts to be retrieved), the "entities" array could possibly be empty. That's really an "edge" scenario - let's say you have retrieved the N-1 "page" and you got the next cursor in the result (ex: there are still 3 contacts to retrieve). Then, while you are processing this N-1 page result in your code and before you make the request using the next cursor, someone happens to delete these 3 contacts which were not retrieved yet (that's why I said it is a scenario at the "edge" :-) ). When you make the request with the next cursor, the request will then return the "last page" with 0 elements in the "entities" array -> "entities: []
You have probably seen that page already but if not, here is the link to the Scan Endpoint Overview. it provides a good explanation on the Scan Endpoints.
Regards,
Zack_Turnbow | 2020-09-24 13:15:04 UTC | #3
Jerome,
Thank you, that was exactly what I was looking for.
system | 2020-10-25 13:15:08 UTC | #4
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
This post was migrated from the old Developer Forum.
ref: 8896