Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
bobiloco
Contributor III
Contributor III

Guidance on using REST 'Next Token' to connect to Commerce7

I've been trying to set up a REST connector to pull all the values from the Commerce7 Orders API.

I'm not sure if I need to implement a loop or if this should work with just the connection details. Right now I keep pulling the same number of rows each time. 

From their documentation, I should use cursor=start for the first loop and then use the cursor that is returned from the query. 

Any help or examples that you could pass my way would be very helpful!

bobiloco_0-1702573945111.png

bobiloco_1-1702574035753.png

bobiloco_2-1702574055346.png

If I don't put "cursor = start " in the query parameters the select data screen shows Total instead of cursor and only pulls back one page.

bobiloco_3-1702574192929.png

 

 

Labels (3)
1 Solution

Accepted Solutions
Daniel_Pilla
Employee
Employee

Hi @bobiloco ,

If you cannot get it working through the REST Connector's GUI, you can set it to `cursor=start` and then insert the script. Once inserted, you can then add the `WITH CONNECTION` clause to the end and modify it, while putting the entire bit into a loop. This way, each time it loops, you use the `peek()` function to grab the current cursor and then modify the url (or header) to the next cursor -- continuing until either there is no more cursor or it is the same as the one prior (depends on the API and how they handle things). While this is admittedly more complex, it is extremely powerful and will prove a valuable feature to learn. You can see an example on how to use `WITH CONNECTION` here and here.

View solution in original post

3 Replies
Daniel_Pilla
Employee
Employee

Hi @bobiloco ,

If you cannot get it working through the REST Connector's GUI, you can set it to `cursor=start` and then insert the script. Once inserted, you can then add the `WITH CONNECTION` clause to the end and modify it, while putting the entire bit into a loop. This way, each time it loops, you use the `peek()` function to grab the current cursor and then modify the url (or header) to the next cursor -- continuing until either there is no more cursor or it is the same as the one prior (depends on the API and how they handle things). While this is admittedly more complex, it is extremely powerful and will prove a valuable feature to learn. You can see an example on how to use `WITH CONNECTION` here and here.

bobiloco
Contributor III
Contributor III
Author

@Daniel_Pilla  I suspected that this was the way forward and was starting to play with a second connection with different settings. I'll mark this as the answer after I play around a bit! Thank you!

bobiloco
Contributor III
Contributor III
Author

This pointed me in the right direction. In the end I set it to custom pagination and put the cusor in the URL and it is now looping through and pulling back all records.

WITH CONNECTION( URL "https://api.commerce7.com/v1/order?cursor=$(vCursor)",