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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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 II
Resolver II

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
Sept PBI Carousel

Power BI Monthly Update - September 2024

Check out the September 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

Find out what's new and trending in the Fabric Community.