I am struggling getting Celigo to page through thi...
# integrations
a
I am struggling getting Celigo to page through this api response. I can only obtain the first page of results. (this is a trimmed down response)
Copy code
{
  "page_of_records": [
    {
      "record": {
        "totalResults": 256,
        "summaries": [
          {
            "sku": "XYZ123",
            "qualifier": "",
            "totalReceived": 7,
            "allocated": 0,
            "available": 7,
            "onHold": 0,
            "onHand": 7,
          },
          {
            "sku": "ABC123",
            "id": 60789
            "qualifier": "",
            "totalReceived": 19,
            "allocated": 0,
            "available": 19,
            "onHold": 0,
            "onHand": 19,
          }
        ],
        "_links": {
          "self": {
            "href": "/v1/summaries?pgsiz=100&pgnum=1"
          },
          "next": {
            "href": "/v1/summaries?pgsiz=100&pgnum=2"
          }
        }
      }
    }
  ]
}
Paging method in Celigo set to "Page number parameter" with relative uri of "v1/summaries?pgsiz=100&pgnum={{export.http.paging.page}}"
t
Can you screenshot your setup within Celigo? Should look something like this
a
@Tyler Lamparter If I put 1 into Override page number start index, it sets the page to 11. (blank gives me 1) Path to total number of results field is blank because the Celigo description of that field says its the total results per page. (not in total). My api response totalResults is for the entire request. Path to records, I have blank.
Using all your fields, seems okay in the preview. Let me try it all.
t
@AnaFarms ignore the 1 being added to the page, that's a bug when previewing, but works correctly on runtime. I think the wording is a bit confusing there, but it's the path to the total records that we should expect after paging everything. We will count the records and compare against that total number and then stop paging after hitting it.
You potentially could also use custom relative url since your api is telling you what the next page is
{{{previous_page.full_response._links.next.href}}}
🙌 1
a
This worked 100 times better. Thank you!
👍 1
Is it possible to include some sort of if statement on that link handlebar? If the next.href exists? I do not receive a last page http response error, just a handlebar error, thus, receive an error on every run.
Copy code
Message: 
    Failed to generate request url from template: {{{previous_page.full_response._links.next.href}}}. Details: "href" not defined in undefined - 1:26.

  Code: handlebars_template_parse_error

  Source: Resource
t
I assume if it doesn't exist then there are no more pages to get?
Can you fill any of these in to tell IO when to stop paging attempts?
a
If it doesn't exist, there are no more pages to get. HTTP status codes and response bodys in the Custom relative URI are tough as the API doesn't error if I keep throwing in new pages and the Celigo generated error doesn't get caught into those three overrides as best as I can tell.
Only thing I receive is an empty summaries array, but that doesn't seem to jive with these.
t
I would probably go back to the page number then. Did it not work for you when making the change with total results?
a
Page Number did work, and will probably be the route to go eventually. It would require modifications to a script in NetSuite as well or a change in Celigo setup. My issue is that this data is ported to a custom record. With the Page Number, it creates 256 Records for the above example. Whereas the other method generates 1 custom record for all. Just need to figure out best way to modify Page Number to one record.
t
@AnaFarms so you want to group all 256 results together so that you can create a single custom record?
There is a grouping feature, but I don't see in your data a common field that could be used to group by