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.
I am using Power BI to read data from the Azure DevOps REST API.
I want to use PowerQuery to get the pull requests in the ADO instance, and the comment threads associated with this pull requests. Doing this in a traditional programming language would be a 2 step process:
The URL to load the comment threads is:
https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/pullRequests/{p...
I need to somehow query the /threads endpoint and fill in a {pullRequestId} parameter.
Ideally I'd like two takes to show up in Power BI: one for the pull requests and one for the threads.
Solved! Go to Solution.
I found a solution. At a high level:
Specifically, my function definition is:
let
Source = (pullRequestId) => let
Source2 = Json.Document(Web.Contents(Text.Combine({"https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repoName}/pullRequests/", Text.From(pullRequestId), "/threads?api-version=6.1-preview.1"}))),
#"Converted to Table" = Table.FromRecords({Source2}),
#"Removed Columns" = Table.RemoveColumns(#"Converted to Table",{"count"})
in
#"Removed Columns"
in
Source
And my table definition is:
let
Source = Table.SelectColumns( #"Pull Requests" , "value.pullRequestId"),
#"Renamed Columns" = Table.RenameColumns(Source,{{"value.pullRequestId", "pullRequestId"}}),
#"Added Custom" = Table.AddColumn(#"Renamed Columns", "value", each GetPrThread([pullRequestId]))
in
#"Added Custom"
From there you just use Power BI to expand columns as you need.
I found a solution. At a high level:
Specifically, my function definition is:
let
Source = (pullRequestId) => let
Source2 = Json.Document(Web.Contents(Text.Combine({"https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repoName}/pullRequests/", Text.From(pullRequestId), "/threads?api-version=6.1-preview.1"}))),
#"Converted to Table" = Table.FromRecords({Source2}),
#"Removed Columns" = Table.RemoveColumns(#"Converted to Table",{"count"})
in
#"Removed Columns"
in
Source
And my table definition is:
let
Source = Table.SelectColumns( #"Pull Requests" , "value.pullRequestId"),
#"Renamed Columns" = Table.RenameColumns(Source,{{"value.pullRequestId", "pullRequestId"}}),
#"Added Custom" = Table.AddColumn(#"Renamed Columns", "value", each GetPrThread([pullRequestId]))
in
#"Added Custom"
From there you just use Power BI to expand columns as you need.
Hi @HamletDRC ,
I found these similar posts which might be helpful:
Using a REST API as a data source
How to Easily Get Data from Web Source Using Power BI Rest API Calls
Importing data from JSON files and Power BI Rest APIs into Power BI
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
102 | |
53 | |
21 | |
12 | |
12 |