Paged API List

Table: Runn_people

let
    Source = List.Generate(() => 
  [Result = 
    try #"fRunn_api"("projects",1) otherwise null, Page = 1], 
    each List.IsEmpty([Result]) <> true, 
  each [Result = 
    try #"fRunn_api"("projects",[Page] + 1) otherwise null, Page = [Page] + 1], 
    each [Result]
),
    #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error)
in
#"Converted to Table"

Function: fRunn_api

let
    Source = (EndPoint, Page as number) =>

let
    #"PageNo" = "page=" & Number.ToText(Page),

source = Json.Document(
                            Web.Contents(
                                "https://app.runn.io/api/v0/",
                                [
                                    RelativePath = EndPoint & "?" & #"PageNo",
                                    Headers=[
                                        #"Authorization" = ("Bearer " & #"Runn_api_token"),
                                        #"content-type" = "application/json"
                                     ]
            ]
        )
    )


in source
in
    Source

Leave a Comment