Issue with Complete Expression in HTTP Pagination

Hi folks,

I am running into an annoying issue when trying to paginate through responses from a specific API endpoint. The endpoint has a parameter in the response body called “nextLink” which has a (relative) url for the next page.

So far so good, with this I am able to set up the pagination using “Response Contains Next URL” with “Next url” configured as “{{ $vars.api_base_url + $response.body[“nextLink”] }}”.

Where I am hitting a wall is with stopping the pagination. When there is no new page, the endpoint returns the last page without the “nextLink” element in the body - so the absence of this data element denotes the last page. I’ve tried to set the Complete Expression to “{{!$response.body.keys().includes(“nextLink”)}}” which looks to evaluate to true but still results in an error:

Any idea what I am doing wrong here? See full settings below.

To make matters even weirder, if I set the Next URL to something like {{ “<hardcoded_url>” + $response.body[“nextLink”] }} it works fine :huh: