{“code”: 422, “message”: “Invalid date range format for analytics query”}
Step one: the Studio SNIPPET builds a dynamic window using {{interaction.startTime}} and pipes it into REST Proxy at /api/v2/analytics/conversations/details. Step two: the trace log shows a clean JSON body, yet the proxy returns that 422 anyway. Tenant clock is locked to Europe/London. Backend SDK sits at 8.4.2. The dateFrom string definitely matches ISO 8601 when dumped to console. Proxy doesn’t parse it.
The 422 error is almost certainly a timezone handling issue on the backend. CXone’s analytics API is strict about date formats and expects explicit UTC offsets. If you’re passing {{interaction.startTime}} directly, you might be sending local time or a format without the ‘Z’ suffix, which the parser rejects as ambiguous.
The dateFrom and dateTo parameters need to be in strict ISO 8601 format with a ‘Z’ suffix to indicate UTC. Since your tenant’s time zone is Europe/London, ensure the conversion happens before hitting the endpoint. The Studio interaction object usually provides timestamps in UTC, but serialization sometimes drops the offset.
Force the correct format in your REST Proxy configuration by explicitly constructing the date string in the Studio expression to guarantee the ‘Z’ is present:
// Studio Expression for dateFrom
new Date(Date.parse({{interaction.startTime}})).toISOString()
Then, in your JSON body for the analytics call, map it like this:
{
"dateFrom": "{{dateFromISO}}",
"dateTo": "{{dateToISO}}",
"groupBy": ["queueId"],
"metrics": {
"conversations": {
"total": {
"type": "COUNT"
}
}
}
}
Ensure your integration has the necessary permissions to access analytics data. Insufficient permissions can manifest as 422 errors. Also, check that the time range isn’t exceeding the retention policy limits for your organization. If querying a narrow real-time window, consider alternative reporting methods, as the details endpoint is resource-intensive and prone to failure with malformed ranges. Investigate the historical reporting options within CXone for potentially more solid time window handling.