Forum Discussion

akashgera's avatar
akashgera
Helper I
4 years ago
Solved

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 

3 Replies

    • akashgera's avatar
      akashgera
      Helper I

      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.

    • akashgera's avatar
      akashgera
      Helper I

      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.