Create Report in Embed View via PowerBI API

|▌冷眼眸甩不掉的悲伤 提交于 2021-01-28 07:55:47

问题


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!


回答1:


You're using the wrong embedURL... AppTokenReportEmbed is the OLD (deprecated) Workspace Collection way. Since you're using GenerateToken, please put the following embedURL: 'https://embedded.powerbi.com/reportEmbed'




回答2:


You can try using the following Embed URL: https://app.powerbi.com/reportEmbed?reportId=MyReportID123&groupId=MyGroupID123; and provide the ReportID and the GroupID of the report you wish to embed.



来源:https://stackoverflow.com/questions/49177971/create-report-in-embed-view-via-powerbi-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!