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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! 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
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.