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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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