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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Jc_16
Frequent Visitor

Help with API

Hi!!

I'm actually working ina projecto to develop reports using data from an API. However, I can create a connection but the information have pagination.

I want to import all the information, but I can't develop all the code to do it automatically.

Can you help me please!!

 

Here is all the things I have.

 

Jc_16_1-1687896261932.png

 

 

 

code used to acces the invoices

 

let

    invoices = Json.Document(Web.Contents(

        baseUrl & "/api/" & accountKey & "/" & subscriptionKey & "/billing/invoices?page=1&pageSize=10",

        [

            Headers = [

                #"Content-Type"="application/x-www-form-urlencoded",

                #"Authorization"="Bearer " & token

            ]

        ]

    ))

in

    invoices[data]

@Anonymous

3 REPLIES 3
SisterRay
Frequent Visitor

Hi! Could you please add link to API Documentation?

Hi

The link I'm actually using is https://app.rose.primaverabss.com

Hi,

Could you please test this query:

let
// Set the initial page number and page size
pageNumber = 1,
pageSize = 10,

// Define a helper function to fetch invoices for a specific page
fetchInvoices = (page) =>
let
// Generate the URL for the current page
url = baseUrl & "/api/" & accountKey & "/" & subscriptionKey & "/billing/invoices?page=" & Text.From(page) & "&pageSize=" & Text.From(pageSize),

// Fetch the invoices for the current page
invoices = Json.Document(Web.Contents(url, [
Headers = [
#"Content-Type"="application/x-www-form-urlencoded",
#"Authorization"="Bearer " & token
]
])),

// Extract the 'data' field from the fetched invoices
invoiceData = invoices[data]
in
invoiceData,

// Initialize an empty list to store all invoices
allInvoices = List.Combine(List.Generate(() =>
[page = pageNumber, invoices = fetchInvoices(pageNumber)],
each List.Count([invoices]) > 0,
each [
page = [page] + 1,
invoices = fetchInvoices([page])
],
each [invoices]
))
in
allInvoices

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.