问题
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