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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. 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
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.