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
kasife
Helper V
Helper V

Call APi

Hello guys,

I'm trying to call an API, and I'm using the page parameter to make the call. It turns out that this API seems to me to have no pages. How could I adjust the call of this function to be able to page and bring all the lines?

 

 

Function:
(
    page 
)
=>
let
    Fonte = 
        Json.Document(
            Web.Contents(
                "https://company.company.com.br", 
                [
                    RelativePath = "/api/cvio/empreendimento/",
                    Query = 
                    [
                        pagina = Number.ToText(page)

                    ],       
                    Headers = 
                    [
                        accept = "application/json",
                        email = _email,
                        token = _token
                    ]
                ]
            )
        )
in
    Fonte



function call
let
    totalpages = fx_empreendimento(1),
    listOfPages = List.Generate(
        () => [page = 1, data = fx_empreendimento(1)],
        each [page] <= totalpages,
        each [page = [page] + 1, data = fx_empreendimento([page]+1)]
    )
in
    listOfPages

 

 

The error that is returned:
Expression.Error: We were unable to apply field access to the List type.
Details:
Value=[List]
Key=total_pages

kasife_0-1690089596266.png

 

 

2 REPLIES 2
Anonymous
Not applicable

Hi @kasife ,

Whether your problem has been resolved? If yes, could you please mark the helpful post as Answered? It will help the others in the community find the solution easily if they face the same problem as yours. Thank you.

Best Regards

Anonymous
Not applicable

Hi @kasife ,

You can refer the following links to connect API in Power BI Desktop using Web connector:

Power BI Using List.Generate to Reduce API Calls with Pagination - Strategy, solutions & Power BI fo...

How to Use List Generate to Make API calls in Power Query - YouTube

Solved: Using list.generate() to query an endpoint multipl... - Microsoft Fabric Community

And this error may occur when you are trying to access a list element by using a field name instead of an index.  The following links are the ones which have the similar problem as yours, hope they can help you solve your problem.

Solved: Re: Help with List.Generate() in making API calls - Microsoft Fabric Community

vyiruanmsft_0-1690267524707.png

Solved: Expression.Error: We cannot apply field access to ... - Microsoft Fabric Community

Best Regards

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.