Trying to pull live queue stats (waiting count, agents available) using the Genesys Cloud Statistics API from our Android app. The goal is to update a UI indicator without polling the full conversation history. I’m hitting POST /api/v2/analytics/queues/observations/query with the queue ID and a simple date range filter.
Here’s the snippet handling the request:
val url = "https://api.mypurecloud.com/api/v2/analytics/queues/observations/query"
val body = """
{
"dateFrom": "2023-10-27T00:00:00Z",
"dateTo": "2023-10-27T23:59:59Z",
"queueIds": ["my-queue-id"]
}
"""
val response = client.newCall(Request.Builder()
.url(url)
.method("POST", body.toRequestBody("application/json".toMediaType()))
.header("Authorization", "Bearer $token")
.build()).execute()
The response comes back with a 200 OK, but the metrics array is empty or shows data from an hour ago. I’ve checked the intervalId parameter and tried realtime, but nothing changes. Is there a specific groupBy or filter required for real-time data? The docs are vague on whether this endpoint supports true real-time or just near-real-time aggregation.
Also, am I missing a header for the Accept type? Tried application/json and application/vnd.genesis.v1+json with no luck. The SDK wrapper for Kotlin doesn’t seem to have a dedicated method for this specific real-time endpoint, so I’m rolling my own Retrofit call. Frustrating.