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!