The standard paging functionality provided by Connector Builder covers most paging use cases. In situations where the provider requires additional information when paging, the `elements-next-page-token` can be used to pass information about the next request in the response headers.
For example, a provider returns the following paging data on a given request, which will be used to get the next page:
"count": "289", "page": { "next": { "batch": "200", "start": 201 }, "this": { "batch": "200", "start": 1 } }
In the connector post hook, information about the next page can be base64 encoded and returned in the response headers:
// Paging if (body.result && body.result.page && body.result.page.next) { headers["elements-next-page-token"] = CE.b64(JSON.stringify(body.result.page.next)); }
Then in the connector pre-hook, the next page token is decoded and the paging information sent to the provider to fetch the next page:
// Paging if(request_parameters.nextPage) { const nextPage = JSON.parse(CE.decode64(request_parameters.nextPage)); // Send nextPage values to the provider }