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
sujeesh
Helper I
Helper I

How to iteratively pass a header parameter in to a API url to get the complete list from the API.

Hi,

I have a below requirement to iteratively pass a header parameter in to a API url to get the complete list from the API.

1.Load the below API URL

https://vsrm.dev.azure.com/fe-tfs/Advisory%20products/_apis/release/releases?api-version=5.1

The response will load the first 50 sets of data with unique release id in Json format. Also an response header with the name “x-ms-continuationtoken”= 538

 

2.To load the remaining set of list from the API, I need to pass the parameter “x-ms-continuationtoken  =538” to the URL iteratively to get all the list from the API.

 

 I am new to power bi and just started using this tool.. Can someone please help me to get around this requirement.

 

Thanks & Regards,

Sujeesh

1 ACCEPTED SOLUTION
artemus
Microsoft Employee
Microsoft Employee

It will look something like:

 

let
    NextResult = (token) =>
        let
            URL = "https://vsrm.dev.azure.com/fe-tfs/Advisory%20products/_apis/release/releases?api-version=5.1",
            URLWithContinuation = 
                if token = null then
                    URL
                else
                    URL & "&continuationToken=" & token, 
            Content = VSTS.Contents(URLWithContinuation),
            AsJson = Json.Document(Content)[value],
            continuationToken = Value.Metadata(Content)[Headers][#"x-ms-continuationtoken"]?,
            Result = 
                if continuationToken = null then
                    AsJson
                else
                    AsJson & @NextResult(continuationToken)
        in
            Result,
    AsTable = Table.FromRecords(NextResult(null))
in
    AsTable

View solution in original post

4 REPLIES 4
artemus
Microsoft Employee
Microsoft Employee

It will look something like:

 

let
    NextResult = (token) =>
        let
            URL = "https://vsrm.dev.azure.com/fe-tfs/Advisory%20products/_apis/release/releases?api-version=5.1",
            URLWithContinuation = 
                if token = null then
                    URL
                else
                    URL & "&continuationToken=" & token, 
            Content = VSTS.Contents(URLWithContinuation),
            AsJson = Json.Document(Content)[value],
            continuationToken = Value.Metadata(Content)[Headers][#"x-ms-continuationtoken"]?,
            Result = 
                if continuationToken = null then
                    AsJson
                else
                    AsJson & @NextResult(continuationToken)
        in
            Result,
    AsTable = Table.FromRecords(NextResult(null))
in
    AsTable

Hello, I am currently working on a similar project where I need to retrieve complete test points data. I have written a function with testplanid and test suited as parameters.

 

let
  PointsAPICall = (TestPlanId as text,TestSuiteId as text) =>
    let
    Source =
    try
    Json.Document(Web.Contents("https://dev.azure.com/{Org}/{project}/_apis/testplan/Plans",[RelativePath= TestPlanId &"/Suites/" & TestSuiteId & "/TestPoint?api-version=6.0-preview.2"]))
    otherwise
    null
in
    Source
in
  PointsAPICall
But, I am only getting the first batch of test points.  Could you please help me pass "continuationToken" to the above code?
Srikanth7Gunnam_0-1635749460964.png

When I pass the continuationToken parameter, nothing is being retrieved.

 

Thanks in advance,

Sri

Hi,

getting parameter error at

 

AsTable = Table.FromRecords(NextResult(null))

 

when the token is null...any pointers??

Thanks in advance

Thank you @artemus . The solution worked perfectly.

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.

Top Solution Authors