Forum Discussion
Pagination Rest-API with no Link-Header or Response containing pages.
- Anonymous4 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"
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"