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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
jawarren
Regular Visitor

Create Report in Embed View via Power BI API

I am trying to create a new report from a dataset in an embedded view. However, I keep getting "This content isn't available" and the reportEmbed.min.js returning a 403 on render. Within app.powerbi.com I can successfully create and save reports, but as mentioned above the embedded view is not working.

 

I am following this documentation exactly:

https://github.com/Microsoft/PowerBI-JavaScript/wiki/Create-Report-in-Embed-View

 

However, I am generating my embed token via a Power BI API call as documentation allows here:

https://msdn.microsoft.com/en-us/library/mt784614.aspx

 

Here is my server-side, embedToken generation code:

const createReportEmbedTokenForCreation = ({
  accessToken,
  groupId,
  datasetId,
}) =>
  new Promise((resolve, reject) => {
    const url = `https://api.powerbi.com/v1.0/myorg/groups/${groupId}/reports/GenerateToken`;
    const headers = {
      'Content-Type': 'application/x-www-form-urlencoded',
      Authorization: `Bearer ${accessToken}`,
    };
    const form = {
      accessLevel: 'Create',
      datasetId,
      allowSaveAs: true,
    };
    request.post({ url, form, headers }, (err, result, body) => {
      if (err) return reject(err);
      const bodyObj = JSON.parse(body);
      if (bodyObj.error) return reject(new Error(body));
      return resolve(bodyObj.token);
    });
  });

Here is my client-side embed code:

const config = {
  accessToken: embedToken,
  embedUrl: 'https://embedded.powerbi.com/appTokenReportEmbed',
  datasetId: defaultReport.datasetId,
};
const report = powerbi.createReport(
  document.getElementById('ReportEmbed'),
  config,
);

Am I missing some scope some where?

 

Thanks in advance!

2 REPLIES 2
v-ljerr-msft
Microsoft Employee
Microsoft Employee

Hi @jawarren,

 

Here is a similar thread in which some troubleshooting steps are mentioned. Could you go to check if it helps in your scenario? Smiley Happy

Power BI has a tile embed sample, which I verified works correctly with interactive user login. Note, that when you're using Power BI.com, the user needs to be an AAD user and needs to login as themselves for licensing reason.  As someone alluded to in another comment if you want to not use AAD users, you'd use Power BI Embedded, which doesn't require the end user to be an AAD user. 

 

https://powerbi.microsoft.com/en-us/documentation/powerbi-developer-integrate-tile/

 

Can you use your client ID and secret with the above sample and see if it works.  Make sure the application has the following redirect URL configured:

Http://localhost:13526/

 

Usually, you get a 403 when the application does not have appropriate permissions. Remember that if you added permissions (scopes) to the application AFTER the user trusted the application, the user’s token won’t get the new scopes until they remove trust from the application and trust it again. Easiest workaround is to create a new application and use that instead.  Alternative is to manually remove the application using Office 365’s “my apps” feature and then try to use the application again.

 

You might also draw inspiration from several other similar threads from other services:

http://stackoverflow.com/questions/31735264/403-forbidden-from-azure-graph-api

https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-integrating-applica...

https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-developers-guide



 

Regards

jawarren
Regular Visitor

I am trying to create a new report from a dataset in an embedded view. However, I keep getting "This content isn't available" and the reportEmbed.min.js returning a 403 on render. Within app.powerbi.com I can successfully create and save reports, but as mentioned above the embedded view is not working.

 

I am following this documentation exactly:

https://github.com/Microsoft/PowerBI-JavaScript/wiki/Create-Report-in-Embed-View

 

However, I am generating my embed token via a Power BI API call as documentation allows here:

https://msdn.microsoft.com/en-us/library/mt784614.aspx

 

Here is my server-side, embedToken generation code:

 

const createReportEmbedTokenForCreation = ({
  accessToken,
  groupId,
  datasetId,
}) =>
  new Promise((resolve, reject) => {
    const url = `https://api.powerbi.com/v1.0/myorg/groups/${groupId}/reports/GenerateToken`;
    const headers = {
      'Content-Type': 'application/x-www-form-urlencoded',
      Authorization: `Bearer ${accessToken}`,
    };
    const form = {
      accessLevel: 'Create',
      datasetId,
      allowSaveAs: true,
    };
    request.post({ url, form, headers }, (err, result, body) => {
      if (err) return reject(err);
      const bodyObj = JSON.parse(body);
      if (bodyObj.error) return reject(new Error(body));
      return resolve(bodyObj.token);
    });
  });

 

Here is my client-side embed code:

 

const config = {
  accessToken: embedToken,
  embedUrl: 'https://embedded.powerbi.com/appTokenReportEmbed',
  datasetId: defaultReport.datasetId,
};
const report = powerbi.createReport(
  document.getElementById('ReportEmbed'),
  config,
);

Am I missing some scope some where?

 

Thanks in advance!

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

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.

FabCon and SQLCon Highlights Carousel

FabCon & SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.

Users online (16,052)