I’m refactoring our Android app’s analytics dashboard to pull conversation details directly from Genesys Cloud. Previously, we were using a simple page-based approach, but the docs for /api/v2/analytics/conversations/details/query suggest using pageSize and page parameters. However, I noticed that when the dataset gets large, the nextPage token in the response is a cursor string, not a page number.
Here’s the Kotlin code I’m using for the initial request:
val request = AnalyticsQueryRequest()
.pageSize(100)
.page(1)
.dateRange(AnalyticsDateRange().startDate("2023-10-01T00:00:00.000Z").endDate("2023-10-02T00:00:00.000Z"))
val response = analyticsApi.getAnalyticsConversationsDetailsQuery(request)
The first call works fine. I get a nextPage value like eyJpZCI6IjEyMyJ9. My question is: should I be passing this cursor back as the page parameter in the next request, or is there a different header or parameter I need to use?
I tried passing the cursor string into page() again, but the API returns a 400 Bad Request with "message":"Invalid page number". If I use nextPage as a query parameter directly, it seems to work, but the SDK doesn’t expose a nextPage setter on the request object.
Is there a recommended pattern for handling this in Kotlin? Should I be using OkHttp directly to append the nextPage query param, or is there a way to do this with the official SDK without breaking the abstraction? I want to avoid hitting rate limits, so I need to make sure I’m paginating correctly.
Also, does the cursor expire? I’m caching the response for offline viewing, and I’m worried the next page link might become invalid if the underlying data changes. Any insights on the stability of these cursors would be appreciated.