Hello,
I am using the Platform SDK/.Net.
What methodology should I use to handle paginated results for API call results?
Reading posts and examining documentation, I have seen a number of different approaches.
I have been relying on nextUri being provided. I have discovered in some instances nextUri isn't incldued in the response. Using the API explorer I can demonstrate this with GET /api/v2/routing/skills and GET /api/v2/flows/datatables (output shown below). In this example I have explicitly defined the page number and made the page size 2 so that results below are minimal (mentioning this because it might seem strange). In the GET datatables response, no nextUri is present.
I suppose I could also just increase the page number until I don't see anything return in entities. I wanted to get feedback from others on how they have handled this.
GET /api/v2/routing/skills?pageSize=2&pageNumber=1 HTTP/1.1
Host: api.mypurecloud.com
Authorization: Bearer *******************
Content-Type: application/json
{
"entities": [
{
"id": "[redacted]",
"name": "[redacted]",
"dateModified": "2023-02-23T06:54:59Z",
"state": "active",
"version": "1",
"selfUri": "/api/v2/routing/skills/[redacted]"
},
{
"id": "[redacted]",
"name": "[redacted]",
"dateModified": "2023-02-23T06:55:44Z",
"state": "active",
"version": "1",
"selfUri": "/api/v2/routing/skills/[redacted]"
}
],
"pageSize": 2,
"pageNumber": 1,
"total": 182,
"lastUri": "/api/v2/routing/skills?pageSize=2&pageNumber=91",
"firstUri": "/api/v2/routing/skills?pageSize=2&pageNumber=1",
"selfUri": "/api/v2/routing/skills?pageSize=2&pageNumber=1",
"nextUri": "/api/v2/routing/skills?pageSize=2&pageNumber=2",
"pageCount": 91
}
GET /api/v2/flows/datatables?pageNumber=1&pageSize=2 HTTP/1.1
Host: api.mypurecloud.com
Authorization: Bearer *******************
Content-Type: application/json
{
"entities": [
{
"id": "[redacted]",
"name": "[redacted]",
"division": {
"id": "[redacted]",
"name": "Home",
"selfUri": "/api/v2/authorization/divisions/[redacted]"
},
"selfUri": "/api/v2/flows/datatables/[redacted]"
},
{
"id": "[redacted]",
"name": "[redacted]",
"division": {
"id": "[redacted]",
"name": "Home",
"selfUri": "/api/v2/authorization/divisions/[redacted]"
},
"description": "[redacted]",
"selfUri": "/api/v2/flows/datatables/[redacted]"
}
],
"pageSize": 2,
"pageNumber": 1,
"total": 163,
"pageCount": 82
}