Forum Discussion
Pikislavi
2 years agoNew Member
API Pagination based on a field in the previous json
Hi All, I hope someone can help me with this issue Im facing... Im extracting a json from an url with the first record_id. It retreives json with limit of 1000 records. That json contains the min_...
- 2 years ago
Hello Pikislavi,
If my post helped you, please give me a 👍kudos and mark this post with Accept as Solution.
It's difficult to test or verify but I think the bug should be fixed here.let ticket_id = "1", iterations = 20, url = "https://xxxxxxx&min_ticket_id=", data = null, next = "", res= null, FnGetOnePage = (url as text, next_ticket as text) as record => let Source = Json.Document(Web.Contents(url & next_ticket)), data = try Source[meta] otherwise null, next = try Text.From(Source[meta][max_ticket_id]) otherwise null, res = [Data=data, Next=next] in res, GeneratedList = List.Generate( ()=>[i=0, res=FnGetOnePage(url, ticket_id)], each [i]<iterations and [res][Data] <> null, each [i=[i]+1, res=FnGetOnePage(url, [res][Next])], each [res][Data] ), ToTable = Table.FromList(GeneratedList, Splitter.SplitByNothing(), null, null, ExtraValues.Error), Expand = Table.ExpandRecordColumn(ToTable, "Column1", {"max_ticket_id", "min_ticket_id", "count", "order"}, {"max_ticket_id", "min_ticket_id", "count", "order"}) in Expand
Best regards from Germany
Manuel Bolz
🟦Follow me on LinkedIn
🟨How to Get Your Question Answered Quickly
🟩Fabric Community Conference
🟪My Solutions on Github
ManuelBolz
2 years agoResponsive Resident
Hello Pikislavi,
If my post helped you, please give me a 👍kudos and mark this post with Accept as Solution.
It's difficult to test or verify but I think the bug should be fixed here.
let
ticket_id = "1",
iterations = 20,
url = "https://xxxxxxx&min_ticket_id=",
data = null,
next = "",
res= null,
FnGetOnePage = (url as text, next_ticket as text) as record =>
let
Source = Json.Document(Web.Contents(url & next_ticket)),
data = try Source[meta] otherwise null,
next = try Text.From(Source[meta][max_ticket_id]) otherwise null,
res = [Data=data, Next=next]
in
res,
GeneratedList =
List.Generate(
()=>[i=0, res=FnGetOnePage(url, ticket_id)],
each [i]<iterations and [res][Data] <> null,
each [i=[i]+1, res=FnGetOnePage(url, [res][Next])],
each [res][Data]
),
ToTable = Table.FromList(GeneratedList, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
Expand = Table.ExpandRecordColumn(ToTable, "Column1", {"max_ticket_id", "min_ticket_id", "count", "order"}, {"max_ticket_id", "min_ticket_id", "count", "order"})
in
Expand
Best regards from Germany
Manuel Bolz
🟦Follow me on LinkedIn
🟨How to Get Your Question Answered Quickly
🟩Fabric Community Conference
🟪My Solutions on Github
Pikislavi
2 years agoNew Member
Worked perfect! I lost a lot of time trying to make it work. Thanks!!