URL Pagination, but it's buried within the string

This article is very similar to my question.
I’m in a bit of a different boat though. My pagination is buried as a string within a string within the headers - not entity.

I am able to parse with something like $headers.link.split(";")[1]
but this seems brittle.

My GET snap doesn’t like this for a hasNext: $headers.link.contains(‘rel=“next”’)

Hi @salesopsintegration,

Can you try to replace your hasNext expression to: $headers.hasPath(“link”) && $headers.link.contains(“next”), and try this for your nextUrl expression: $headers.link.split(";")[0].replaceAll(’<’,’’).replaceAll(’>’,’’). This should work if the link header containts only the next link, but if some cases include more than the next link, for example if there are prev and last link there would be another solution. Let me know if this helps.

Best regards,
Aleksandar.

1 Like

Hi @salesopsintegration,

I had the similar usecase and I used below expressions for pagination. You can also try the same.
$headers.link.contains(‘rel=“next”’) for hasNext expression and $headers.link.substr($headers.link.indexOf(’<’)+1,$headers.link.indexOf(’>’)-1) for nextUrl expression. Let me know if this helps.

Regards,
Kanika

Hi @salesopsintegration,

Okta is also one of my use cases, so I’ve worked this out before. Here is my approach (there are alternatives to the syntax):

image

For copy/paste…
Has next:    $headers.link.contains("\"next\"")
Next URL:    $headers.link.replace(/^<(.+)>.+/,"$1")

1 Like

Thanks all! I knew I was on the right path - but needed some eagle eyes to point me in the right direction.