Forum Discussion

adityamohanty's avatar
adityamohanty
New Contributor II
18 days ago
Solved

Pagination Logic Fails After Migrating from REST GET to HTTP Client Snap

Hello everyone, Three years ago, I developed a pipeline to extract data from ServiceNow and load it into Snowflake. As part of this, I implemented pagination logic to handle multi-page responses b...
  • ssapa's avatar
    ssapa
    13 days ago

    adityamohanty​ First, I’d like to understand the change you mentioned. After adding the condition $headers.get('link') != null, were you able to retrieve all the records? In other words, is your Snap performing pagination and fetching data from all pages?

    From what I understand, with the above change, your Snap might validate successfully, but it likely won’t perform pagination, since $headers.get('link') will always return null.

    As mentioned in my earlier comment, to enable pagination, you need to update the Has Next and Next URL expressions as shown below.

    Pagination → Has Next:

    isNaN($headers['Link'].match(/",<([^;"]*)>;rel="next",/))

    Override URI → Next URL:
    $headers['Link'].match(/\",<([^;\"]*)>;rel=\"next\",/) ? $headers['Link'].match(/\",<([^;\"]*)>;rel=\"next\",/)[1].replace(_servicenow_cloud_base_url, _servicenow_b2b_base_url) : null

    Regarding the sysparm_display_value parameter — by default, this value is set to false. If you’d like to return all columns (both displayValue and value), make sure to include the query parameter "sysparm_display_value=all".

    I’ve attached a sample pipeline created using our test ServiceNow endpoint. With this configuration, I was able to run the pipeline successfully with pagination enabled and also able to fetch both displayvalue and value columns.