REST API paging options

Hi,
I’m trying to setup a workflow using the REST API to retrieve lists of endpoints from various sites within an endpoint management system we use. So far its authenticating, retrieving the bearer token, using that to retrieve the list of sites and then looping through the sites to retrieve the endpoint lists and it’s working well.

The problem is the API will only retrieve the first 50 endpoints in a site and most sites have more than 50 endpoints - the API responses do include a nextPagekey value which I’ve used in Powershell scripts with the same API to loop and build up a single endpoint array, but how can i use this key to loop through all pages until I’ve processed all pages within an insightConnect workflow?

Ideally i’d like the result to be a single array of all endpoints that i can then cycle through in the next loop, but another option could be to loop through the first 50, then retrieve the next page of 50 and so on, but I can’t work out how to do either at the moment so any help would be helpful.

Thanks in advance

1 Like

You might take a look at our Cancel Jobs Workflow for an idea on how to do this. Essentially, you will have to create a loop that will loop a max number of times you think you will be needed to loop to get all pages and then break once you reach the end of pages. The difficulty will lie in using the page variable from the output or your initial and subsequent requests. Since we don’t have workflow variables that can be updated during each job you will need to create a Global Artifact(GA) to store the page number and max pages initially. Your workflow would then use and delete that variable and then create the next page number GA for the next loop iteration.