Question

Returning all pages of data from an action search

  • 22 June 2023
  • 2 replies
  • 74 views

Badge +1

I’m using a REST API’s method that returns results in pages.  I’d like this to be the source of a “Search” action (basic integration; not CLI).

What’s the recommended way to retrieve all pages?

** edit ** 

I read that a polling trigger may work for this.  The API returns data in this format:

{
"hasMoreResults": true,
"continuationToken": "00000002-0000-0000-c800-000000000000",
"additionalResultsUrl": "/v1/legalentities/00000/employeesIdentifyingData?continuationToken=00000002-0000-0000-c800-000000000000",
"records": [
{
"firstName": "First",
"lastName": "Last",
"socialSecurityNumber": "00000000",
"employeeId": "00000000-0000-0000-0000-00000000",
"employeeNumber": "012345",
"birthDate": "2000-01-01T00:00:00",
"status": "Active"
},
...
]
}

Can this be used with the bundle.meta.page value?


This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

2 replies

Userlevel 7
Badge +14

Hi @benjamink9 

Good question.

To clarify, are you trying to do this in a Zap or part of the Zapier Developer Platform?

 

That will depend on the app API endpoint you are using.

Generally API results are pagination because there could be lots of results.

That means logic has to be applied to loop thru all the available pages to get the results.

Badge +1

I am attempting to do this in an integration, not a Zap.

To page this endpoint, I need to repeatedly supply the continuationToken as a parameter, until the hasMoreResults is false or the continuationToken is null.

Can this be done within a search action without having to convert the integration to a CLI project?

I think I would prefer to use an action rather than a trigger, as the former has the “Pair an existing search and a create to enable "Find or Create" functionality?” option.

Can the code in “Configure your API Request (step 1)” be adapted to page this API in the manner that I describe?