cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Paginated REST GET calls against Monday.com

OhSnap
New Contributor II

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:
monday.query

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.

monday.rest.get
monday_results

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!

1 ACCEPTED SOLUTION

OhSnap
New Contributor II

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.

mapper

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:

HasNext

(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:

page_incrementer

Hope this helps!

View solution in original post

2 REPLIES 2

aleung
Contributor III

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.

OhSnap
New Contributor II

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.

mapper

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:

HasNext

(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:

page_incrementer

Hope this helps!