Forum Discussion
How to create a custom dynamic list for REST API pagination?
- 4 years ago
Hi bikelley
This code will create your list
let Source = Record.FromList({12958},{"TotalResultCount"}), TotalResultCount = Source[TotalResultCount], DynamicList = List.Generate(() => 2000, each _ < TotalResultCount, each _ + 2000), FinalList = List.Combine({DynamicList, {TotalResultCount}}) in FinalListI've set up a dummy record in the Source step so that I can simulate getting the TotalResultCount. You can modify this to suit your own query structure.
Regards
Phil
- 4 years ago
Hi bikelley
Change the FinalList step to this
FinalList = List.Combine({{1}, DynamicList, {TotalResultCount}})Regards
Phil
Hi bikelley
This code will create your list
let
Source = Record.FromList({12958},{"TotalResultCount"}),
TotalResultCount = Source[TotalResultCount],
DynamicList = List.Generate(() => 2000, each _ < TotalResultCount, each _ + 2000),
FinalList = List.Combine({DynamicList, {TotalResultCount}})
in
FinalList
I've set up a dummy record in the Source step so that I can simulate getting the TotalResultCount. You can modify this to suit your own query structure.
Regards
Phil
- bikelley4 years agoHelper IV
Hi PhilipTreacy
Thank you so much for your help.
This is working, but the only issue is the List not starting from 1. Can please tell me is there any way we can add 1 before 2000. Now I am not getting the first 2000 records.List
1
2000
4000
6000
8000
10000
12000
12958This my Power Query with your code,
let Source = Json.Document(Web.Contents("https://rally1.rallydev.com/slm/webservice/v2.0/defect?workspace=https://rally1.rallydev.com/slm/webservice/v2.0/workspace/331029809496&query=&fetch=true&start=1&pagesize=20000", [Headers=[zsessionid="**************"]])), QueryResult = Source[QueryResult], TotalResultCount = QueryResult[TotalResultCount], DynamicList = List.Generate(() => 2000, each _ < TotalResultCount, each _ + 2000), FinalList = List.Combine({DynamicList, {TotalResultCount}}) in FinalListPlease let me know the way I can add 1. Thank you so much