12-09-2021 03:32 PM
Wondering if anyone has done paginated REST GET calls to Monday.com? I’m trying to figure out how to structure the “Have Next” and “Next URL” parameters to the snap.
The query in Monday looks like this:
It’s this JSON string that gets passed to the service URL as a “query” parameter. The pagination index is embedded in the JSON.
So I’ve got my snap configured with the URL + url encoded query parameter specified in the Service URL, and “jsonPath($, “entity.data.items_by_column_values[*]”).length > 0” as my Has Next, and this:
“https://api.monday.com/v2?query={items_by_column_values%20(board_id%3A%201328675272%2C%20column_id%3...” + (snap.out.totalCount + 1).toString() + “%2C%20limit%3A%2010%29%7B%0Aid%2Cname%0Acolumn_values%20%28ids%3A%5B%22country69%22%2C%22text97%22%2C%22text024%22%2C%22micro_location0%22%2C%22commission%22%2C%22text03%22%2C%22numbers38%22%2C%22electricity_fee%22%2C%22text68%22%2C%22text4%22%2C%22visibility___accessibility%22%5D%29%7B%0Aid%2Ctype%2Ctext%2Ctitle%7D%7D%7D”
as my Next URL. I’m expecting “(snap.out.totalCount + 1).toString()” to provide the page increment to embed into the URL query parameter.
I’m only getting the first service call, and no iterations of the Next URL. I’ve tried all kinds of permutations in the Has Next in trying to get anything to work. Frustrating that we don’t just have a simple checkbox that says call this Next URL until you don’t see anything new show up, and some auto-increment counter that just counts up from 1 on every Next URL call.
Any help would be much appreciated!
Solved! Go to Solution.
12-10-2021 01:15 PM
Thanks aleung, that was super helpful. Finally got it solved.
To anyone trying to debug their paging REST GET calls, here’s what I did.
Connect your REST GET snap to a mapper and create a single call out to your fetching API.
Let the validation of these two snaps fill in the object definition on the mapper and then open the mapper. I selected and dragged over the encompassing array for the items being populated from the GET call. The length of this returned array then became my condition for Has Next:
(ie. if it was able to fetch records on this call, then assume it has more to fetch.)
Paging to the next page, was accomplished with this code inclusion:
Hope this helps!
12-09-2021 03:47 PM
The easiest way to debug is to use a mapper after your REST Get and placed your expression in 2 fields for HasNext and Next URL to ensure it is correct.
12-10-2021 01:15 PM
Thanks aleung, that was super helpful. Finally got it solved.
To anyone trying to debug their paging REST GET calls, here’s what I did.
Connect your REST GET snap to a mapper and create a single call out to your fetching API.
Let the validation of these two snaps fill in the object definition on the mapper and then open the mapper. I selected and dragged over the encompassing array for the items being populated from the GET call. The length of this returned array then became my condition for Has Next:
(ie. if it was able to fetch records on this call, then assume it has more to fetch.)
Paging to the next page, was accomplished with this code inclusion:
Hope this helps!