cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
TesDA
Responsive Resident
Responsive Resident

GET Restful API - Loop through offset requests

I have a Restful API request using the HTTP Step:

 

Method - Get

Authentication - Raw

Value - API key

 

It picks up everything on the first call correctly, but I dont know how to create the loop so that it continues until there are no more records.

 

Below is the JSON returned from the initial request (from the first set of records). How do I create a variable and loop through so that it uses the "next" in the JSON until "next" returns null?

 

{"count":7816,
"next":"https://blackedoutname.endpointname.com/api/v1/something/?_limit=4000&_offset=4000&include_custom_fi...",
"previous":null,
"results":[
{
"id":"9172391872397a",
"jurisdiction":{
"id":"kajhdkjhasdkjhb",
"name":"ABCDEF",
"slug":"ABCDEFno"},
"organization_person":{
"id":"kahdkjahdh",
"custom_fields":{},
"person":{
"id":"kajshdkhd",
"username":"65432","first_name":"Nate",
"last_name":"Smith",
"email":"Nate.Smith@something.com"}},
"is_primary":false,
"status":"active",
"in_compliance":false,
"start_date":"1995-01-01",
"end_date":"1996-12-31",
"extended_date":"1997-12-31",
"earned":5765.0,
"applied":5740.0,
"overall_deficit":1000.0,
"overall_applied":5740.0,
"carry_over":0.0,
"license_id":"",
"latest_annual_period":{
"id":"kasdkjahsdh",
"in_compliance":false,
"start_date":"1997-01-01",
"end_date":"1998-12-31",
"extended_date":"1999-12-31",
"earned":0.0,
"applied":0.0,
"overall_applied":0,
"overall_deficit":1000.0,
"carry_over":0.0}}]}

1 ACCEPTED SOLUTION

Accepted Solutions
TesDA
Responsive Resident
Responsive Resident

I finally figured this one out. In the returned JSON is a next, with the next http statement for the next download of json. I created a variable to pick up the "next" from the parsed JSON and then did a do until loop until next = null:

 

Step 1 - Initialize Variable

 

"next" is initially set to the initial http address.

 

Next variable.jpg

 

Step 2 - Do Until loop

 

I set the count to 4 (it was defaulted to 60), since I know the API should only need to loop 2-3 times.

 

Do Until Loop.jpg

View solution in original post

3 REPLIES 3
TesDA
Responsive Resident
Responsive Resident

Additional information added to the summary

yeamans
Helper I
Helper I

'm having a similar issue. I have 100s of records with a system, however I can only call 100 at a time. I need to figure out how to loop through the pages. 

 

I do get presented with s string "record": 857

 

Would i need to create a variable based upon dividing the total records by 100 then rounding up the next whole number? 

 

Flow-Fastbound.png

 

flow-fastbound-skip.png

 

 

TesDA
Responsive Resident
Responsive Resident

I finally figured this one out. In the returned JSON is a next, with the next http statement for the next download of json. I created a variable to pick up the "next" from the parsed JSON and then did a do until loop until next = null:

 

Step 1 - Initialize Variable

 

"next" is initially set to the initial http address.

 

Next variable.jpg

 

Step 2 - Do Until loop

 

I set the count to 4 (it was defaulted to 60), since I know the API should only need to loop 2-3 times.

 

Do Until Loop.jpg

View solution in original post

Helpful resources

Announcements
MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Carousel

Sign up for our May 4th event!

May the fourth be with you, join us online!

MSFTBizAppsLaunchEvent

Experience what’s next for Power Virtual Agents

See the latest Power Automate innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Top Solution Authors
Top Kudoed Authors
Users online (60,362)