Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
cheesepudding
Regular Visitor

Problems Embedding using REST API

 

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: 

Screen Shot 2017-11-21 at 11.01.14 am.pngScreen Shot 2017-11-21 at 11.01.02 am.png

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.

1 ACCEPTED 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.


@cheesepudding

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.

 

View solution in original post

2 REPLIES 2
cheesepudding
Regular Visitor

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.


@cheesepudding

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.

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.