I’m trying to pull real-time observation data for a specific queue using the Genesys Cloud Statistics API. Specifically, I need the waiting count and agents available right now, not historical aggregates.
I’m using the Node.js SDK (@gencloud-ops/genesys-cloud) in a Lambda function. Here’s the call:
const { AnalyticsApi } = require('@gencloud-ops/genesys-cloud');
const analytics = new AnalyticsApi();
const data = {
queueId: 'a1b2c3d4-e5f6-7890-abcd-ef1234567890',
interval: 'realtime',
metricIds: ['queue/waiting/count', 'agent/available/count'],
groupBy: ['queueId']
};
try {
const response = await analytics.postAnalyticsQueuesRealtime(data);
console.log(response.body);
} catch (error) {
console.error('API Error:', error.statusCode, error.message);
}
The endpoint returns a 400 Bad Request with the message Invalid request body. The interval must be a valid ISO 8601 duration or 'realtime'.
I’ve checked the Swagger docs, and realtime seems correct for the interval field in the postAnalyticsQueuesRealtime endpoint. I’ve also tried passing 'PT0S' or omitting the interval entirely, but I keep hitting the same wall.
Is the Node.js SDK mapping the interval string incorrectly? Or is there a specific format required for the metricIds array when requesting real-time data?
Here’s the exact error payload I’m getting back:
{
"message": "Invalid request body.",
"status": 400,
"code": "bad.request",
"errors": [
{
"message": "The interval must be a valid ISO 8601 duration or 'realtime'.",
"field": "interval"
}
]
}
I’ve logged the raw request body before sending it, and it looks exactly like the object defined above.
Any ideas on why the SDK is choking on realtime? I’m running version 1.2.4 of the SDK.