cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sujeesh
Helper I
Helper I

Unable to authenticate the Azure DevOps rest API

Hi,

While using the below code to to get the api content iteratively, i am getting the authentication error. Can some one help me to resolve this issue

 

let
// Define the base URL of the Work Item Link REST API
baseUrl = "https://dev.azure.com/@@@@/@@@@/_apis/wit/workItemLinks",

// Define the request options for the Work Item Link REST API
requestOptions = [
Headers = [
#"Content-Type" = "application/json",
#"Authorization" = "Bearer *******************************"
],
Query = [
#"api-version" = "6.1-preview.3",
#"sourceIds" = "123",
#"$top" = "100"
]
],

// Define a recursive function to retrieve all the work item links using the continuationToken
getWorkItemLinksRecursive = (requestOptions as record, links as list) =>
let
// Call the Work Item Link REST API with the specified requestOptions and retrieve the links
response = Json.Document(Web.Contents(baseUrl, requestOptions)),
newLinks = links & response[value],
continuationToken = response[#"continuationToken"]
in
// If there is a continuationToken, call the function again with the updated requestOptions and links
if continuationToken <> null then
let
newRequestOptions = requestOptions & [Query = requestOptions[Query] & [#"continuationToken" = continuationToken]],
newLinks = getWorkItemLinksRecursive(newRequestOptions, newLinks)
in
newLinks
// If there is no continuationToken, return the final list of links
else
newLinks,

// Call the recursive function to retrieve all the work item links
allLinks = getWorkItemLinksRecursive(requestOptions, {})
in
// Transform the links data as needed
allLinks

 

 

1 REPLY 1
ferryv
Resolver I
Resolver I

I'd suggest trying: Json.Document(VSTS.Contents(baseUrl, requestOptions)) instead of Json.Document(Web.Contents(baseUrl, requestOptions)) for API calls (your response step). I typically have more success with that when using the API instead of oData.

 

You might have to rewrite some of the subsequent steps accordingly also. 

 

I wrote this article https://www.linkedin.com/pulse/retrieve-long-text-fields-from-azure-devops-powerbi-van-der-vorst/?tr... previously on LinkedIn, where I used an API. It might get you on your way also.  

Helpful resources

Announcements
PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

MPPC 2023 PBI Carousel

Power Platform Conference-Power BI and Fabric Sessions

Join us Oct 1 - 6 in Las Vegas for the Microsoft Power Platform Conference.

Top Solution Authors