CLI autopaginate

Just looking for help with the -a flag in the CLI
And maybe it doesn't work how I want it to.
My understanding is it would go through each page automatically returning all possible results. - I suspect I am wrong.

Using powershell in Windows, in have
.\gc.exe routing queues members list -a SomeQueueID
For a queue that has 120 members

The result is only the first 25 agents.

Ultimately i'm trying to create a CSV of all agents in a division and what queues they have, and what skills they have. Basically looking to create a skill matrix in csv format, based on what they actually have so it can be compared to what they should have.

Getting the agents by queues is the tricky part,
So far I have
(.\gc.exe routing queues list -a | ConvertFrom-Json) | Where-Object name -eq "QueueName" | Select-Object id | ForEach-Object {(.\gc.exe routing queues members list $_.id -a | .\jq-win64.exe '{Name: .[].user.name}' )}

And it gives me a list of user's names in that Queue, but again only the first 25.

I suppose I could set the --pageSize flag to something really big?

Any help with either just getting the full list, or if someone has done something similar and has any easier way to do it I'm all ears.

Hi Anton,

I'm not sure why this isn't working correctly for you.
You can use the -i flag or --indicateprogress to print progress data, this should indicate if it is autopaginating or not.
You can also use the full version of the -a flag: --autopaginate.

If it paginates correctly then the output will be an array. If it does not paginate then the output will look something like the following:

{
  "entities": [...],
  "pageSize": 25,
  "pageNumber": 1,
  "total": 120,
  "firstUri": "/api/v2/routing/queues/3e771132-ad69-4737-b3dc-d86771cd09a0/members?pageSize=25&pageNumber=1",
  "selfUri": "/api/v2/routing/queues/3e771132-ad69-4737-b3dc-d86771cd09a0/members?pageSize=25&pageNumber=1",
  "nextUri": "/api/v2/routing/queues/3e771132-ad69-4737-b3dc-d86771cd09a0/members?pageSize=25&pageNumber=5",
  "lastUri": "/api/v2/routing/queues/3e771132-ad69-4737-b3dc-d86771cd09a0/members?pageSize=25&pageNumber=5",
  "pageCount": 5
}

Setting the --pageSize flag to something really big will unfortunately not work because the maximum value is 100.

If you are still having trouble after trying the above suggestions I'll set up a Windows environment to test this issue.

Thanks Ronin

using -a or --autopaginate is the same, it does return an array [] rather than an object, but it only returns the first 25 entries. and -i shows an &pageSize=25 in the uri.

.\gc.exe routing queues members list -a -i QueueID gives the below output, not sure where its getting the pagesize from

Command started at: 2022-01-06T07:53:08.3850265+13:00. Method: GET, Path: /api/v2/routing/queues/QueueID/members?pageNumber=1&pageSize=25
Command finished at: 2022-01-06T07:53:08.6359291+13:00. Time taken: 250.9026ms

Envirnoment wise, I'm on Windows 11, Powershell version 5.1.22000.282,
CLI/GC version 22.0.0

I've checked on a Windows server 2019 machine with PowerShell version 5.1.17763.2268 and it worked ok.

I did notice that the -i flag will not indicate that it's paginating if there is a small number of results.

The only other suggestion I can give is to upgrade to the latest CLI version. In that CLI version, you will have the gc autopagination command. You can use gc autopagination enable to permanently enable autopagination for supported commands.

Thanks for taking a look.
Even on the newest version of the CLI and using gc autopagination enable
No luck.

It works fine for ".\gc.exe -i users list"
I can see it working through all the pages
ie I get

Command started at: 2022-01-07T08:47:24.3731445+13:00. Method: GET, Path: /api/v2/users?pageSize=25&pageNumber=1
Paginating with URI: /api/v2/users?pageSize=25&pageNumber=2
Paginating with URI: /api/v2/users?pageSize=25&pageNumber=3
etc
And seems to work fine for other commands like scripts and flows. Even routing queues list works fine.

but for routing queues members list ".\gc.exe routing queues members list -i QueueID" it doesn't and yes there is definitely more thank 1 page, if I don't autopaginate it gives the next page uri, if i change page size or page number manually there are more results. I have tried multiple different queues.

all i get is

Command started at: 2022-01-07T08:48:12.0093905+13:00. Method: GET, Path: /api/v2/routing/queues/e9ac59e9-70b8-477b-93fd-44cc875b2fdc/members?pageNumber=1&pageSize=25
Command finished at: 2022-01-07T08:48:12.3104845+13:00. Time taken: 301.094ms
[
{
"id": etc

So something specific to the routing queues member list cmd

I've managed to find the bug. The members endpoint does not return a pageCount value, unlike the others. The pagination logic was dependent on this value to determine how many pages are in the response. I have updated the pagination logic to use nextUri instead.

I've published version 29.0.1 with the fix. You can download it using the following link: gc.exe

1 Like

Thanks Ronan.

That is awesome.

Hi Roan, I have just used gc 29.0.1 on mac doing gc -p XXX analytics conversations details query create and it returns no pagination information - only totalHits value and 100 entries (based on request)

Hi Mike,

The CLI doesn't currently support pagination for POST calls. It is a feature we may look to implement in future but for now, users will have to manually paginate for POST API calls such as this one.

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.