Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

Power BI Service cant connect to Devops API with PAT. While desktop works fine.

Hey Everyone, 

I try to connect to the azure devops API to get team capacity, sprints etc using the following URL;

https://dev.azure.com/[organization]/[projectname]/[teamname]/_apis/work/teamsettings/iterations?api-version=7.0

and this is the query; 

 

 

let
    Source = VSTS.Contents("https://dev.azure.com/[organization]/[projectname]/[teamname]/_apis/work/teamsettings/iterations?api-version=7.0"),
    #"Imported JSON" = Table.FromRecords(Json.Document(Source,65001)[value]),
    #"attributes uitgevouwen" = Table.ExpandRecordColumn(#"Imported JSON", "attributes", {"startDate", "finishDate", "timeFrame"}, {"attributes.startDate", "attributes.finishDate", "attributes.timeFrame"}),
    #"Type gewijzigd" = Table.TransformColumnTypes(#"attributes uitgevouwen",{{"attributes.startDate", type datetime}, {"attributes.finishDate", type datetime}}),
    #"Type gewijzigd1" = Table.TransformColumnTypes(#"Type gewijzigd",{{"attributes.startDate", type date}, {"attributes.finishDate", type date}})
in
    #"Type gewijzigd1"

 

 

At first i used Oauth2.0 to get this data, and this works fine on Desktop. But as soon as i publish that to the Service i get errors because of MFA. As i login from a different place (the power bi server) it needs MFA to login. 

So to bypass this i decided to make a Personal Access Token (PAT). But unfortuniatly i get the same result. PAT works perfectly fine on desktop, but generates the following error on the service; 

The credentials provided for the Visual Studio Team Services source are invalid.

Also, about the MFA, i dont really get it. Because Oauth works fine with other sources. 
for example, i also use Devops analytics views to get the workitems from the last 30 days and that works perfectly fine with Oauth on desktop and service. So if anyone could explain me more about why VSTS.Contents doesnt work and VSTS.AnalyticsViews works fine.