Hey folks,
I’m trying to export a full month of conversation details for a client using the REST API. The endpoint is POST /api/v2/analytics/conversations/details/query.
According to the docs, if I set size to a high number, it should handle pagination via the nextPageToken in the response. I’ve been looping through the calls like this:
body = {
"dateFrom": "2024-01-01T00:00:00.000Z",
"dateTo": "2024-01-31T23:59:59.000Z",
"size": 1000,
"groupBy": []
}
while True:
response = requests.post(url, json=body, headers=headers)
data = response.json()
process(data['entities'])
if 'nextPageToken' in data:
body['nextPageToken'] = data['nextPageToken']
else:
break
The first batch comes back fine with 1000 records. But when I pass the nextPageToken back into the body for the second call, the API returns an empty array [] even though I know there are more records. The nextPageToken field disappears from the second response too.
I’ve tried lowering the size to 100, same issue. Is this endpoint actually supporting cursor pagination properly, or am I missing a header? The analytics team keeps pointing me to the docs, but the code isn’t working as expected.