Forum Discussion
400 Bad Request Error when embedding report
- Anonymous6 years ago
Hi shaw
If you are using the 'App owns data' type of embedding + using the Service Principal to generate embedding tokens, then this Identity section of the token request should contain details of the 'user' used for Row Level Security purposes.
Are you reports/dashboards using Row Level Security?
If so... your identity section should look like this..."identities": [ { "username": "[email protected]", "roles": [ "My PBI Role Name" ], "datasets": [ "cfafbeb1-8037-4d0c-896e-a46fb27ff229" ] } ]Username can be any value - you are effectively impersonating this person - and this has no link to any account in your Azure tenant or Power BI access list.
Roles should contain any Power BI (RLS) roles that you have defined inside your data model. Note that you should not supply roles here if you are not using RLS - and dont supply roles that dont exist in your model. Again, this is not a role that belongs to your Service Principal account or any other Power BI account type (admin/member/viewer) etc..Hope this helps,
Cheers - Matt
Hi Anonymous
Imagine, I have a 'School ID' set as a role (Power BI role) as an RLS field. How do I pass on the 'School ID' to the Ajax call from the alien application?
Javascript (Ajax Call with School ID) > Alien application's Java code in order to embed the Power BI report?
Technically saying:
I would like to pass on the "school ID" that I got as a global variable in the alien application readily available to pass on. I couldn't figure out how it is done on the https://microsoft.github.io/PowerBI-JavaScript/demo/v2-demo/index.html# .
my School ID is a column from the table called "SchooldDetails"
report. <I pass on the constructed table and column info to this object? >
$.ajax({
type: "GET",
url: "/appownsdatasample/getembedinfo",
dataType: "json",
success: function (embedData) {
reportLoadConfig["accessToken"] = embedData["embedToken"];
reportLoadConfig["embedUrl"] = embedData["embedUrl"];
// Use the token expiry to regenerate Embed token for seamless end user experience
// Refer https://aka.ms/RefreshEmbedToken
tokenExpiry = embedData["tokenExpiry"]
// Embed Power BI report when Access token and Embed URL are available
report = powerbi.embed(reportContainer, reportLoadConfig);
// Triggers when a report schema is successfully loaded
report.on("loaded", function () {
console.log("Report load successful");
});
// Triggers when a report is successfully embedded in UI
report.on("rendered", function () {
console.log("Report render successful");
});
Hi shaw
Apologies for the lack of response, the last few weeks have been difficult to say the least.
Are you still having issues with RLS and getting your ID's to the right place?
Happy to continue the discussion if you are stuck.