Running into a wall with the Analytics API. We need to pull conversation details for the last quarter to feed the custom desktop app, but the endpoint keeps rejecting the payload.
The request hits GET /api/v2/analytics/conversations/details/query. The body looks like this:
{
"dateFrom": "2023-10-01T00:00:00.000Z",
"dateTo": "2023-12-31T23:59:59.999Z",
"select": ["conversationId", "startTime", "duration"],
"size": 500
}
Getting a straight 413 Entity Too Large response. The error body says the request exceeds the maximum allowed size.
My thought process here is that the query engine is pre-calculating the result set size based on the date range before it even hits the pagination layer. A 90-day window with high volume is obviously going to blow past whatever limit is in place.
I’ve tried breaking this down using the SDK. The logic looks something like this in the client code:
val analyticsApi = AnalyticsApi()
var currentFrom = startDate
while (currentFrom <= endDate) {
val dateTo = minOf(currentFrom.plusDays(7), endDate)
val query = AnalyticsQueryBody()
.dateFrom(currentFrom)
.dateTo(dateTo)
.select(listOf("conversationId"))
val response = analyticsApi.postAnalyticsConversationsDetailsQuery(query)
// process response
currentFrom = dateTo.plusDays(1)
}
The split approach works for smaller chunks, but I’m losing track of the pagination cursor across the date boundaries. The nextPageUri seems to reset or invalidate when I change the date parameters for the next loop iteration.
The docs mention splitting queries but don’t give a concrete example on how to chain the pagination tokens safely across multiple date windows.
The 413 error doesn’t give a specific byte count or row limit. Just the generic message. Makes debugging this a bit of a shot in the dark.