How to apply pagination to JSON

I have found an example for XML, but i can't find anything recent about setting up pagination for JSON except for this article but it is outdated (2015) and i want to know if there is a simple way of implementing it?

Please refer to the policies that are needed and how to implement and configure them. if there is another example which is more recent that would also be enough for me to look into

Solved Solved
1 2 1,086
1 ACCEPTED SOLUTION

Here's a shared flow that paginates a JSON response: https://github.com/apigee/consumer-data-standards-au/tree/master/src/shared-flows/paginate-backend-r...

And here's another shared flow that adds pagination links: https://github.com/apigee/consumer-data-standards-au/tree/master/src/shared-flows/add-response-heade...

The format is very specific to a standard, but you can get an idea on how to do this.

You'll need to set the following flow variables to true for the behaviour to kick in:

  • pagination.doPagination
  • generatePaginationLinksAndMeta

The following variables must also be set:

  • pagination.page: The page number to return
  • pagination.page-size: The size of each page

It also uses some variables that hold info about the Proxy URI, needed to build a link to "self", these are set by an extract variables policy: https://github.com/apigee/consumer-data-standards-au/blob/master/src/shared-flows/check-request-head.... You should have such a policy in a request flow.

View solution in original post

2 REPLIES 2

Here's a shared flow that paginates a JSON response: https://github.com/apigee/consumer-data-standards-au/tree/master/src/shared-flows/paginate-backend-r...

And here's another shared flow that adds pagination links: https://github.com/apigee/consumer-data-standards-au/tree/master/src/shared-flows/add-response-heade...

The format is very specific to a standard, but you can get an idea on how to do this.

You'll need to set the following flow variables to true for the behaviour to kick in:

  • pagination.doPagination
  • generatePaginationLinksAndMeta

The following variables must also be set:

  • pagination.page: The page number to return
  • pagination.page-size: The size of each page

It also uses some variables that hold info about the Proxy URI, needed to build a link to "self", these are set by an extract variables policy: https://github.com/apigee/consumer-data-standards-au/blob/master/src/shared-flows/check-request-head.... You should have such a policy in a request flow.

Fantastic!