Hey folks,
We’re pulling conversation detail data for our WFM adherence reports. The goal is to grab every single interaction for a specific date range. I’m hitting the /api/v2/analytics/conversations/details/query endpoint.
The first page comes back fine. I see the nextPageToken in the response. I pass that token into the next request as the pageToken parameter. But the second page comes back with count: 0 and an empty entities array. This happens even though I know there are thousands of records for that day.
Here is the Python snippet I’m using. We’re just doing a simple loop until the token is gone.
import requests
base_url = "https://api.mypurecloud.com/api/v2/analytics/conversations/details/query"
headers = {
"Authorization": f"Bearer {access_token}",
"Content-Type": "application/json"
}
params = {
"dateFrom": "2023-10-01T00:00:00.000Z",
"dateTo": "2023-10-01T23:59:59.999Z",
"viewId": "all",
"pageSize": 500
}
all_data = []
page_token = None
while True:
if page_token:
params["pageToken"] = page_token
response = requests.get(base_url, headers=headers, params=params)
if response.status_code != 200:
print(f"Error: {response.status_code}")
print(response.text)
break
data = response.json()
if not data.get("entities"):
print("No more entities found")
break
all_data.extend(data["entities"])
print(f"Fetched {len(data['entities'])} records. Total so far: {len(all_data)}")
page_token = data.get("nextPageToken")
if not page_token:
break
print(f"Total records collected: {len(all_data)}")
The output looks like this:
Fetched 500 records. Total so far: 500
No more entities found
Total records collected: 500
I checked the docs. It says to use pageToken for cursor-based pagination. I’m doing that. Am I missing a parameter? Or is there a limit on how many pages I can chain together in one session?
Also tried setting viewId to our custom WFM view but same result. Any ideas on what’s breaking the chain after the first 500?