โ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!