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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
GunterM
Regular Visitor

Error creating new reports using Power BI Embedded

Hi,

 

I've written the following code to try create a new report using Power BI Embedded:

 

authContext.acquireToken(window.config.endpoints.powerbiUri, function (error, token) {

                let datasetId = $("#datasetId").val();
                let embedContainer = $("#embedContainer").get(0);
           
                let models = window['powerbi-client'].models;

                let config = {
                    accessToken: token,
                    datasetId: datasetId,
                    embedUrl: "https://embedded.powerbi.com/appTokenReportEmbed"
                };

                let report = powerbi.createReport(embedContainer, config);

                report.on("saved", function (event) {
                    let msg = `report saved ${JSON.stringify(event.detail, null, "  ")} `;
                    alert(msg);
                });

                report.on("error", function (event) {
                    let msg = `error creating report saved ${JSON.stringify(event.detail, null, "  ")} `;
                    console.log(msg);
                });

            });

 

 

Everytime the code runs, an NotAuthorized error is logged however. The account that I used to test my code has admin permissions on Power BI.

 

error creating report saved {
  "message": "CreateReportFailed",
  "detailedMessage": null,
  "technicalDetails": {
    "requestId": "4a909e2f-4552-0433-13ed-3e9a3d2346b2"
  },
  "errorCode": "NotAuthorized"
} 

What is wrong with my security ? I'm using the "User owns data" scenario btw...

Gunther

1 REPLY 1
v-ljerr-msft
Microsoft Employee
Microsoft Employee

Hi @GunterM,

 

It seems to be that the embedded token is invalid. How did you get the token? 

 

In addition, here is similar thread which should help you make sure the token is valid. Smiley Happy

 

Regards

Helpful resources

Announcements
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.

May 2025 Monthly Update

Fabric Community Update - May 2025

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