I’m trying to pull agent state history for the last 24 hours using the CXone Reporting API v2, specifically hitting /api/v2/reporting/agents/states/history. I’ve got the OAuth token sorted and the permissions look fine, but every POST request I send back a 400 Bad Request. The documentation for the OData-style query parameter is a bit sparse on exact date formatting requirements, so I’m guessing it’s something dumb with the JSON payload structure. Here’s the snippet I’m using in Node.js to construct the request body:
const payload = {
"dateFrom": "2023-10-25T00:00:00.000Z",
"dateTo": "2023-10-26T00:00:00.000Z",
"groupBy": ["agentId", "stateName"],
"interval": "PT1H"
};
const response = await axios.post(
`${baseUrl}/api/v2/reporting/agents/states/history`,
payload,
{ headers: { 'Authorization': `Bearer ${token}`, 'Content-Type': 'application/json' } }
);
The error message is just "message": "Invalid query parameter" with no specifics on which field is tripping it up. I’ve tried changing the interval to PT30M and even removing the groupBy array entirely, but nothing sticks. It feels like the API is choking on the date range or maybe expecting a different format for the OData filter syntax. I’m used to the Genesys Cloud analytics endpoints being more forgiving with ISO strings, so this is throwing me off. Has anyone successfully queried this specific endpoint recently? I’m at a loss because the standard date format seems correct to me, and I’ve double-checked the timezone offsets. The endpoint definitely exists and my user has the reporting:report:read scope, so it’s not an auth issue. I’m starting to think there might be a hidden requirement for the groupBy field or maybe the interval needs to align with some internal bucket size. I’ve also tried using the filter parameter with standard OData syntax like $filter=stateName eq 'Available', but that just makes the 400 error worse. I’m stuck on this one and the docs aren’t giving me the clues I need to move forward. Any ideas on what’s missing from the payload?