Forum Discussion
Tip for anyone trying to connect PBI Desktop to VSTS REST API
- 8 years ago
I just found an even better way to do this. The trouble with the above implemenation is with the API call - it only returns 100 items and you have to page through it! A bit tricky using Power BI.
Here is some code for another API call to use that will return a user list in CSV. I just used Fiddler to see what call it makes when you click on the "Export Users" functionality on VSTS.
let Source = (Web.Contents("https://<<ACCOUNT NAME>>.vsaex.visualstudio.com/DefaultCollection/_apis/MEMInternal/Export?api-version=3.1-preview")), #"Imported CSV" = Csv.Document(Source,[Delimiter=",", Columns=6, Encoding=65001, QuoteStyle=QuoteStyle.None]), #"Promoted Headers" = Table.PromoteHeaders(#"Imported CSV", [PromoteAllScalars=true]), #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Name", type text}, {"Username", type text}, {"Access Level", type text}, {"Last Access", type text}, {"Test Manager", Int64.Type}, {"Package Management", Int64.Type}}) in #"Changed Type"
I just found an even better way to do this. The trouble with the above implemenation is with the API call - it only returns 100 items and you have to page through it! A bit tricky using Power BI.
Here is some code for another API call to use that will return a user list in CSV. I just used Fiddler to see what call it makes when you click on the "Export Users" functionality on VSTS.
let
Source = (Web.Contents("https://<<ACCOUNT NAME>>.vsaex.visualstudio.com/DefaultCollection/_apis/MEMInternal/Export?api-version=3.1-preview")),
#"Imported CSV" = Csv.Document(Source,[Delimiter=",", Columns=6, Encoding=65001, QuoteStyle=QuoteStyle.None]),
#"Promoted Headers" = Table.PromoteHeaders(#"Imported CSV", [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Name", type text}, {"Username", type text}, {"Access Level", type text}, {"Last Access", type text}, {"Test Manager", Int64.Type}, {"Package Management", Int64.Type}})
in
#"Changed Type"