Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hello all,
The API i'm trying to get info from is : https://avisi-apps.gitbook.io/tracket/api/worklog-api
Which basically returns in a JSON format worklogs that employees did.
First I have to get a Bearer Token to authenticate, this part is done.
But I have another issue for paginate other this until the end.
I have an error that blocks me, I think I did the most of it but still missing a point here.
For the moment I have only 2 pages which I get like :
I do this that way because we have a cursor id in all pages except the last one which next-cursor is equal to null.
I basically want a way to fetch all pages until he gets no next-cursor or a next-cursor equals to null which means that's the last page.
Here is my code :
Source = Json.Document(Web.Contents("https://v1-gateway-9e6mvodx.uk.gateway.dev/api/1.0/worklogs",[Headers = [#"Content-Type"="application/json", #"Authorization"=token]])),
#"Converted to Table" = Record.ToTable(Source),
#"Transposed to Table" = Table.Transpose(#"Converted to Table"),
#"Promoted Headers" = Table.PromoteHeaders(#"Transposed to Table", [PromoteAllScalars=true]),
data = let
Pagination = List.Generate( ()=> Source,
each [worklogs] <> null,
each
if Record.HasFields(_, "next-cursor")
then Json.Document(Web.Contents("https://v1-gateway-9e6mvodx.uk.gateway.dev/api/1.0/worklogs?next=" & Text.From([#"next-cursor"]), [Headers=[Authorization=token]] ))
else
if [#"next-cursor"] = null
then Json.Document(Web.Contents("https://v1-gateway-9e6mvodx.uk.gateway.dev/api/1.0/worklogs", [Headers=[Authorization=token]] ))
else Record.FromList({null, null}, {"worklogs", "next-cursor"} ))
in
Pagination,
#"Converted to Table1" = Table.FromList(data, Splitter.SplitByNothing(), null, null, ExtraValues.Ignore),
#"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table1", "Column1", {"worklogs", "next-cursor"}, {"worklogs", "next-cursor"})
in
#"Expanded Column1"
Let me know if it's unclear or you need more information,
VB
Solved! Go to Solution.
Hello all,
Instead of deleting my answer, I've found the solution here : https://community.powerbi.com/t5/Power-Query/Web-based-cursor-pagination-issue/m-p/2784393
Good luck
Hello all,
Instead of deleting my answer, I've found the solution here : https://community.powerbi.com/t5/Power-Query/Web-based-cursor-pagination-issue/m-p/2784393
Good luck
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 1 | |
| 1 | |
| 1 |
| User | Count |
|---|---|
| 10 | |
| 6 | |
| 4 | |
| 4 | |
| 3 |