Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Pagination Rest-API with no Link-Header or Response containing pages.

Hi everyone, Since i've been working on this issue for some time now, i thought i might try my luck here. I haven't really found anything that exactly solved my issue in related posts. and i'm stru...
  • Anonymous's avatar
    Anonymous
    4 years ago

    Solved importing it although it resulted in a nested Table, so not as easy to work with. which i'm what im doing now. Feel free to alter the code. I'm sure it can be optimised.

    This is what i did in the main Query :
    #"super_list" = List.Generate(()=>[page=1,Funct = Convert_Page_Table(1)], each (try[Funct])[HasError]=false, each [page=[page]+1,Funct=Convert_Page_Table([page]+1)]),
    #"Page_list" = Table.FromRecords(#"super_list"),

    This is the custom function I implemented : 
    (PageValue)=>
    let
    url= "https://XYZ.mocoapp.com/api/v1/schedules?from=2021-01-01&to2021-12-31&page=",
    token = [Headers=[Authorization="Token token=XXX"]],
    Source = Json.Document(Web.Contents(Text.Insert(url,82,Text.From(PageValue)), token)),
    #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error)
    in
    #"Converted to Table"