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
glauberludwig
New Member

Iterate and Join Tables Over Dynamic API Pages With Power Query

Hello Folks!

 

I'm using Power Query to retrieve specific financial data (bills that are not paid "situation=3") from my ERP's API.

 

The API data Query is "normal", like http://erpsite.com/api/financial.data.php?token=1234&format=json&situation=3&page=1

 

My problem is that their API retrieve only the first 100 records, so if I have 102 records, for example, I need to query [...]&page=2 to get the table with 2 records. I have never reached so far 100 records, but that has just happened this month.

 

Here is the basic code, where I get data from Excel (token changes every week, that's why I have a Dynamic "URL")

 

let
apiAddress = Excel.CurrentWorkbook(){[Name="URL"]}[Content]{0}[Column1],
Source = Json.Document(Web.Contents(apiAddress), 65001),
#"Converted to Table" = Record.ToTable(Source),
#"Value Expandido" = Table.ExpandRecordColumn(#"Converted to Table", "Value", {"status_processamento", "status", "pagina", "numero_paginas", "notas_servico"}, {"Value.status_processamento", "Value.status", "Value.pagina", "Value.numero_paginas", "Value.notas_servico"}),
in
#"Value Expandido"

This code gives me a table like this, with a List of service_notes that I expand to get the 100 records filtered with "situation=3":

namestatus_processamentostatusidpagenumber_pagesservice_notes
retorno3OK34578712List

 

Since I'm from Brasil, in the code "pagina" means "page" and "numero_paginas" means "number_pages".

 

As you can see, the table gives me the page number that I used in the URL [...]&page=1 (actually, if I put no page number, it is the same as page=1) and the total number of pages, that has only been 1 so far.

 

I need a solution to dynamically loop and give me a single table with all the records, "fixing" this 100 records limitation.

 

So what I think should be the steps:

  • Inicial Query without page parameter or with page=1 and get the number_pages value.
  • Loop number_pages times changing dynamically the URL with page=[actual value]
  • Combine each query in a single table and gives me a 

I know now my URL parameter includes &page= parameter, but of course I should remove that and dynamically set it.

 

How can I perform something like that?

 

Thanks for your attention!

1 ACCEPTED SOLUTION
v-yanjiang-msft
Community Support
Community Support

Hi @glauberludwig ,

Please see if this document can help:

Defining and using parameters in API page - Dynamics 365 Business Central Forum Community Forum

 

Best Regards,
Community Support Team _ kalyj

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-yanjiang-msft
Community Support
Community Support

Hi @glauberludwig ,

Please see if this document can help:

Defining and using parameters in API page - Dynamics 365 Business Central Forum Community Forum

 

Best Regards,
Community Support Team _ kalyj

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Yes, that way also could help, but I was able to perform my solution with this video.

 

https://www.youtube.com/watch?v=05yhwnuCjRw

 

This was exacly what I needed: get the page number and them perform dynamic queries.

 

Thanks!

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