Forum Discussion

P3UAL's avatar
P3UAL
Frequent Visitor
8 years ago
Solved

Tip for anyone trying to connect PBI Desktop to VSTS REST API

After struggling for months trying to use Power Bi to extract a VSTS user list (UserEntitlements) along with their subscription level with little on the internet. I finally got it working. The diffic...
  • P3UAL's avatar
    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"