I’m hitting a wall trying to list all queues across multiple divisions using the genesys-cloud-platform-client SDK in JavaScript. The standard platformClient.queues.getQueues() call only returns queues for the authenticated user’s default division. That makes sense, but we have a setup where agents are spread across division/1, division/2, and division/3. I need to aggregate all of them into a single array for a dashboard widget.
I’ve tried looping through the division IDs I have stored and calling getQueues with the divisionId parameter, but the response seems inconsistent. Sometimes it returns an empty array even though I know queues exist in that division. Other times it throws a 403 Forbidden error claiming insufficient permissions, despite the service account having queue:view and queue:view:all scopes.
Here’s the basic loop I’m using:
const divisions = ['division/1', 'division/2', 'division/3'];
let allQueues = [];
for (const div of divisions) {
try {
const queues = await platformClient.queues.getQueues({ divisionId: div });
allQueues = [...allQueues, ...queues.entities];
} catch (err) {
console.error(`Failed for division ${div}:`, err);
}
}
The issue is that getQueues has pagination. I’m only getting the first 25 items per division. I tried adding pageSize: 500 and pageNumber: 1, but that feels hacky. Is there a cleaner way to handle pagination automatically in the SDK? Or is there a bulk endpoint I’m missing that fetches across all divisions at once?
Also, the 403 errors are annoying. I checked the OAuth token scopes and they look correct. Is there a specific permission required on the division level itself to query queues via the API? The docs mention queue:view but don’t clarify if that applies to other divisions.
I’ve been digging through the SDK source code for a listAll helper method but didn’t find anything useful. Feels like I’m reinventing the wheel here. Any tips on handling the pagination loop cleanly or fixing the permission issue?