Forum Discussion

Tommy's avatar
Tommy
New Contributor III
5 years ago
Solved

Pagination from JSON Path Has Next URL - Trustpilot

Hello, I am trying to call a rest get API with some pagination. The API returns the next page URL within the response, so i should be able to use this in the snap. I am getting the value usi...
  • del's avatar
    5 years ago

    I believe the main issue is jsonPath is returning an array, so for Next URL you will need to index it with [0].

    jsonPath($, "$entity.links[?(@.rel=='next-page')].href")[0]

    And with it producing an array, a more appropriate Has next condition might be to check for the array length > 0. (Yet I suspect it will work as-is in this specific use case.)

    jsonPath($, "$entity.links[?(@.rel=='next-page')].href").length > 0