We’re building a custom agent desktop widget using the Embeddable Client App SDK and need to populate a dropdown with all queues across multiple divisions. I’m using the queuesApi from @genesyscloud/flow-connector or the standard platform SDK, but the pagination logic seems to hang when crossing division boundaries. I have a recursive function that calls getQueues with pageSize=100 and checks nextPageToken. It works fine for the first division, but when the token points to the next division, the promise resolves with an empty array instead of the next set of data. The code looks like this:
async function getAllQueues(apiInstance) {
let allQueues = [];
let nextPageToken = null;
do {
const response = await apiInstance.getQueues({
pageSize: 100,
nextPageToken: nextPageToken
});
if (response.entities) {
allQueues = [...allQueues, ...response.entities];
nextPageToken = response.nextPageToken;
}
} while (nextPageToken);
return allQueues;
}
The issue is that response.nextPageToken becomes null prematurely, even though we know there are more queues in the eu-west-1 division. I’ve verified the OAuth token has the read:queue scope and read:division permissions. The network tab shows the last request returning a 200 OK with an empty entities array, which breaks the loop. I’m wondering if the SDK handles cross-division pagination differently than the raw REST API, or if I’m missing a specific parameter to force fetching all divisions. I’ve tried adding divisionId in the query, but that limits it to one division, which defeats the purpose. We need a reliable way to fetch every queue regardless of division without hitting the API limit. The current approach feels fragile and I can’t find documentation on how the SDK handles this specific multi-division edge case. Any ideas on why the token expires early or if there’s a better method?