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.
Hi,
I'm trying to embed a report using workspace collections while utalizing row level security. I'm using javascript and hence the Power Bi REST API.
I understand that the steps are:
Get access token from azure AD [1] -> get embed token (with access parameters passed in) from power bi -> place embedded content on your website.
I'm using the following REST POST call to get my access token. This works fine.
> POST /common/oauth2/token HTTP/1.1 > Host: login.windows.net > Content-Type: application/x-www-form-urlencoded | client_id=<app_client_id>&grant_type=password&resource=https%3A%2F%2Fanalysis.windows.net%2Fpowerbi%2Fapi&username=<powerbi_username>&password=<powerbi_password>&client_secret=<app_client_secret>
Since my report is in a workspace collection, the only things I can see using the command line is collection name, workspace ID, and report ID. In the following REST API call, you can see that it needs a group ID and a report ID. I have the report ID but not sure how to go about getting the group ID. I also understand that the row level security access is defined in the body, so I don't have a problem with the RLS part.
POST https://api.powerbi.com/v1.0/myorg/groups/{group_Id}/reports/{report_id}/GenerateToken { "accessLevel": "View", "identities": [ { "username": "EffectiveIdentity", "roles": [ "Role1", "Role2" ], "datasets": [ "fe0a1aeb-f6a4-4b27-a2d3-b5df3bb28bdc" ] } ] }
Currently I'm generating the embed token using the powerbi CLI tool. I'm using the command:
powerbi create-embed-token -c <collection_name> -k <access_key> -w <workspace_ID> -r <report_ID>
When I do embed, I get the following errors:
I'm embedding using:
<html> <body> <div id="reportContainer"></div> <script src="./node_modules/powerbi-client/dist/powerbi.min.js"></script> <script> (function () { var embedToken = '<token from powebi create-embed-token>'; var reportId = '<report id from workspace collections>'; var embedUrl = 'https://embedded.powerbi.com/appTokenReportEmbed?reportId=' + reportId; var config = { type: 'report', accessToken: embedToken, embedUrl: embedUrl, id: reportId, settings: { filterPaneEnabled: false, navContentPaneEnabled: false } }; powerbi.embed(document.getElementById('reportContainer'), config); })(); </script> </body> </html>
Any thoughts?
Thank you.
Solved! Go to Solution.
@cheesepudding wrote:
Reading further into documentation, I noticed that Power BI Workspace Collections is going to not be avaiable soon due to the Power BI Premium release. Are the steps the same when it comes to getting the embed token (i.e. is there going to be a group ID for my report).
Thanks.
Just to clarify.
The legency Power BI Embedded workspace collections uses a set of Azure REST APIs. As to authenticating and authorizing, you can reference this page.
As to the replacement, Power BI Embedded capacity-based SKUs, you would get access token with the POST API in your original post and then get embed token with this API GenerateToken. In the new PBI Embedded, you publish pbix file to Power BI service instead of to the legency Power BI Embedded workspace. So you can simply get the group id from Power BI Service site UI or you can simply get the id by calling the API Get Groups.
power BI embedded vs Power BI Rest API for your reference.
Reading further into documentation, I noticed that Power BI Workspace Collections is going to not be avaiable soon due to the Power BI Premium release. Are the steps the same when it comes to getting the embed token (i.e. is there going to be a group ID for my report).
Thanks.
@cheesepudding wrote:
Reading further into documentation, I noticed that Power BI Workspace Collections is going to not be avaiable soon due to the Power BI Premium release. Are the steps the same when it comes to getting the embed token (i.e. is there going to be a group ID for my report).
Thanks.
Just to clarify.
The legency Power BI Embedded workspace collections uses a set of Azure REST APIs. As to authenticating and authorizing, you can reference this page.
As to the replacement, Power BI Embedded capacity-based SKUs, you would get access token with the POST API in your original post and then get embed token with this API GenerateToken. In the new PBI Embedded, you publish pbix file to Power BI service instead of to the legency Power BI Embedded workspace. So you can simply get the group id from Power BI Service site UI or you can simply get the id by calling the API Get Groups.
power BI embedded vs Power BI Rest API for your reference.
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 |
---|---|
12 | |
2 | |
2 | |
1 | |
1 |
User | Count |
---|---|
20 | |
3 | |
2 | |
2 | |
2 |