Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
akashgera
Helper I
Helper I

Dealing with paginated API using Recursion function

Hello Folks,

I am using paginated API to fetch the data as per page number , one single page fetches only 100 records and total I have 30824 records which requires data from 309 pages. So I want here is to write a m code in power query which will change the page number on its own through the loop/iterative method till page 309 and union all the above pages.

Pls look into my M code below:

let
url = "https://fxxxxxxxxxxxxxxxxxx/prod/api/V1/catalog",
header= [#"x-api-key" = "XXXXXXXXXXXXX",
#"Content-Type" = "application/json"],
body=[
page_no=1,                    // Want to change this page no. dynamically after returning the previous list until page 309
page_size=100
],

webdata = Web.Contents(url, [Content = Json.FromValue(body),Headers=header]),
response = Json.Document(webdata),
items1 = response[items]
in
items1

 

Pls help.! @ImkeF 

1 ACCEPTED SOLUTION
mahoneypat
Employee
Employee

Please see this video for a potentially simpler way to do this.  Also, have you tried to increase the page_size value to get >100 in each web call?

Power BI - Tales From The Front - REST APIs - YouTube

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

3 REPLIES 3
mahoneypat
Employee
Employee

Please see this video for a potentially simpler way to do this.  Also, have you tried to increase the page_size value to get >100 in each web call?

Power BI - Tales From The Front - REST APIs - YouTube

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Dear Mahoneypat,

I have watched your video and got the resolution, thank you so much for providing the help, you have saved my day today..🙏

Kudos to you and your skill set.👍

People like you are much needed in this PBI community.

Hello sir,

Thanks for the response, I have tried to increase the page size >100, but unfortunately it is not giving me more than 100 records, So the max. limit of records per web call is 100 only.

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors
Top Kudoed Authors