Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
VBLOT
Helper I
Helper I

API REST Tracket Cursor Based Pagination

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 :

VBLOT_0-1677856937789.png

 

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

1 ACCEPTED SOLUTION
VBLOT
Helper I
Helper I

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

View solution in original post

1 REPLY 1
VBLOT
Helper I
Helper I

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

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.