Reputation: 38
I am trying to Embed PowerBI Dashboards into ASP.Net Web application. I have written the code to input App Workspace GUID in Textbox and based on input id binding list of all Dashboards in Dropdown there after end-users can select the Dashboard from Dropdown and get the Embed URL. Refer attached screen-shot.
As per the client's feedback, I need to replace Workspace Id input field with dropdown, and bind list of Workspace GUIDs dynamically, from where end-users can select the workspace Id and get list of dashboards.
I have looked into below sample, however couldn't find any methods to get list of Workspace GUIDs. https://github.com/Microsoft/PowerBI-Developer-Samples
How can i get list of all PowerBI Workspace GUIDs? Is there any API to get list of Workspaces in Power BI?
Upvotes: 1
Views: 2863
Reputation: 2254
In the API they use 'group' in place of workspace so you want the group part of the API https://learn.microsoft.com/en-us/rest/api/power-bi/groups
Specifically GetGroups which will return all the workspaces that the passed in user has access to.
In rest terms
GET https://api.powerbi.com/v1.0/myorg/groups?$filter={$filter}&$top={$top}&$skip={$skip}
Power BI Client
using (var client = new PowerBIClient(new Uri(ApiUrl), tokenCredentials))
{
// Get a list of workspaces.
var workspaces = await client.Groups.GetGroupsAsync();
}
Upvotes: 2