cancel
Showing results for 
Search instead for 
Did you mean: 

URL Pagination, but it's buried within the string

salesopsintegra
New Contributor II

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.
Screen Shot 2022-03-07 at 7.54.45 PM

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”’)

1 ACCEPTED SOLUTION

del
Contributor III

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")

View solution in original post

4 REPLIES 4

Aleksandar_A
Contributor III

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.

Kanika
New Contributor

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

del
Contributor III

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")

salesopsintegra
New Contributor II

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