Forum Discussion

kasife's avatar
kasife
Helper V
3 years ago

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

 

 

2 Replies