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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
brunofranc
Frequent Visitor

API Get Data JSON with Pagination

Hello,  

 

I'm trying to build a rotine to get all pages of JSON Data Souce API.

The limit is 1000 results per page, if in the Page´s bottom is write " "hasMore": false " i means "there is no more pages." but it is "true" is the oposite.

How can we build a query for this  JSON and append all in one document.

 

Query:

let
Fonte = Json.Document(Web.Contents("https://api.fakeurl.com/reports/0155?page=1&limit=1000&begin=18/02/2020&end=31/12/2020", [Headers=[Authorization="eyJ0eXAiOiJKV1QiLChbGciOiJGW-L48"]])),
data = Fonte[data],
report = data[report],
result = report[result]
(...)

 

Botton of JSON Result:

                    "Revenue": 4683.5,
                    "number": 8,
                    "ticket": 585.44,
                    "date": "2020-05-14",
                    "dateMonth": "14/5",
                    "dayname": "4"
                }
            ],
            "hasMore": false
        }
    }
}

 

2 REPLIES 2
mahoneypat
Microsoft Employee
Microsoft Employee

It might be easier to approach this differently.  Do the below in a single query.  

 

1. Make a web call to get the total # of records with $count (or whatever the syntax is for your API)

2. Divide that by 1000 and round down

3. Make a list from 1 to the number in step 2 and convert list to table, change to text type and name it Page

4. Pass the Page value into the url string (either hard code it into an Add Custom column, or make a function)

5. Append all the tables

 

If this solution works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

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



When did you say:
"Make a web call to get the total # of records with $count (or whatever the syntax is for your API)"

I didn't find this ...

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.

Top Solution Authors