CXone Reporting API v2: Querying Agent State History with OData filter fails on time range

Trying to pull agent state history for the last 24 hours using the CXone Reporting API v2. We’ve got a hybrid setup here in Sydney and the reporting latency is annoying us, so we need accurate data for our hybrid platform dashboard.

I’m trying to query agent status history with a time range filter. The docs suggest using query parameters for the start and end times. Here’s the snippet I’m working with in Python:

import requests
import jwt

# ... auth setup omitted for brevity ...

headers = {
 'Authorization': f'Bearer {token}',
 'Accept': 'application/json'
}

params = {
 'startTime': '2023-10-27T00:00:00Z',
 'endTime': '2023-10-28T00:00:00Z',
 'agentUserId': 'agent-123'
}

response = requests.get('https://api.us.niceincontact.com/api/v2/quality/agents/activity', headers=headers, params=params)
print(response.status_code)
print(response.text)

It’s returning a 400 Bad Request. The error payload looks like this:

{
 "code": "badRequest",
 "message": "Invalid query parameters",
 "details": "Could not parse time range"
}

I’ve tried wrapping the dates in quotes, escaping the T, and even using dateTime casts. Nothing works. I’m used to Genesys Cloud APIs being a bit more forgiving with ISO 8601 strings, but this is strict.

Is there a specific format CXone expects for the startTime and endTime query parameters? I’ve checked the Swagger spec but it’s vague on the exact string format for these parameters in this endpoint. We need this for a compliance report that runs nightly. Any pointers on the correct syntax? I’ve been staring at this for an hour and it’s driving me nuts.