Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Please, help.
I'm using SalesforceAppOwnsDataEmbedding to display a Dashboard in Salesforce, everything works well, inclusively I'm able to send Report Level Filters.
However, if Row Level Security is used in Dashboard, then error occurs.
(Displayed error) Generate Token Error: OK
(Internal Error) Bad Request, Error 400
I already tried using identities for api body with no success.
Not sure if App Registration in Azure requires specific permission over the PowerBi Service Api. (read/write)
Thanks in advance!
Class method where error occurs:
// Call to Power BI Service API to get embed token for report
HttpRequest reqGetEmbedToken = new HttpRequest();
reqGetEmbedToken.setMethod('POST');
String urlGetEmbedToken = 'https://api.powerbi.com/v1.0/myorg/groups/' + WorkspaceId + '/reports/' + ReportId + '/GenerateToken';
reqGetEmbedToken.setEndpoint(urlGetEmbedToken);
System.debug('new method with devEnv as Identity');
reqGetEmbedToken.setHeader('Authorization', 'Bearer ' + access_token);
reqGetEmbedToken.setBody(
'{'
+'"datasets": [{"id": "'+powerBiReport.datasetId+'"}]'
+',"reports": [{"id": "'+powerBiReport.id+'"}]'
+',"identities":['
+'{"username":"appRegistrationObjectId","roles":["Security"],"datasets":["'+powerBiReport.datasetId+'"]}'
+'{"username":"appRegistrationClientId","roles":["Security"],"datasets":["'+powerBiReport.datasetId+'"]}'
+']'
+'}');
System.debug('complete reqGetembedToken varialbe debugging '+reqGetEmbedToken.getBody());
HttpResponse responseEmbedToken = http.send(reqGetEmbedToken);
Solved! Go to Solution.
Finally achieved this embedding!!! 🎉
Sharing solution in case someone's struggling with something similar.
My scenario was; I'm using a POST call to endpoint API GenerateTokenInGroup, my Dahsboard uses RLS, so it is required to include "identities" in the "Request Body" json, seems like I was not including all the required data on each section of the HttpRequest.
Important!
Full HttpRequest code
// Call to Power BI Service API to get embed token for report
HttpRequest reqGetEmbedToken = new HttpRequest();
reqGetEmbedToken.setMethod('POST');
String urlGetEmbedToken = 'https://api.powerbi.com/v1.0/myorg/groups/' + WorkspaceId + '/reports/' + ReportId + '/GenerateToken';
reqGetEmbedToken.setEndpoint(urlGetEmbedToken);
System.debug('setEndpoint = '+urlGetEmbedToken);
reqGetEmbedToken.setHeader('Authorization', 'Bearer ' + access_token);
reqGetEmbedToken.setHeader('Content-Type', 'application/json');
system.debug('setHeader = '+reqGetembedToken.getHeader('Authorization'));
reqGetEmbedToken.setBody(
'{'
+'"accessLevel":"View"'
+',"identities":['
+'{"username":"1eac8b84-11a3-4f67-b308-c9ab0a7b8da0","roles":["noRlsFilters"],"datasets":["'+powerBiReport.datasetId+'"]}'
+']'
+'}');
System.debug('setBody = '+reqGetEmbedToken.getBody());
HttpResponse responseEmbedToken;
try {
responseEmbedToken = http.send(reqGetEmbedToken);
System.debug('http send successfully');
system.debug(responseEmbedToken);
} catch (Exception error) {
system.debug('Error Catched');
System.debug(error);
}
Response code is now 200 and Token is successfully generated,
Dashboard is displaying and filtering is correctly applying.
Hooray!
Finally achieved this embedding!!! 🎉
Sharing solution in case someone's struggling with something similar.
My scenario was; I'm using a POST call to endpoint API GenerateTokenInGroup, my Dahsboard uses RLS, so it is required to include "identities" in the "Request Body" json, seems like I was not including all the required data on each section of the HttpRequest.
Important!
Full HttpRequest code
// Call to Power BI Service API to get embed token for report
HttpRequest reqGetEmbedToken = new HttpRequest();
reqGetEmbedToken.setMethod('POST');
String urlGetEmbedToken = 'https://api.powerbi.com/v1.0/myorg/groups/' + WorkspaceId + '/reports/' + ReportId + '/GenerateToken';
reqGetEmbedToken.setEndpoint(urlGetEmbedToken);
System.debug('setEndpoint = '+urlGetEmbedToken);
reqGetEmbedToken.setHeader('Authorization', 'Bearer ' + access_token);
reqGetEmbedToken.setHeader('Content-Type', 'application/json');
system.debug('setHeader = '+reqGetembedToken.getHeader('Authorization'));
reqGetEmbedToken.setBody(
'{'
+'"accessLevel":"View"'
+',"identities":['
+'{"username":"1eac8b84-11a3-4f67-b308-c9ab0a7b8da0","roles":["noRlsFilters"],"datasets":["'+powerBiReport.datasetId+'"]}'
+']'
+'}');
System.debug('setBody = '+reqGetEmbedToken.getBody());
HttpResponse responseEmbedToken;
try {
responseEmbedToken = http.send(reqGetEmbedToken);
System.debug('http send successfully');
system.debug(responseEmbedToken);
} catch (Exception error) {
system.debug('Error Catched');
System.debug(error);
}
Response code is now 200 and Token is successfully generated,
Dashboard is displaying and filtering is correctly applying.
Hooray!
Hi @DanielRamos ,
It's glad to hear that your problem has been resolved. And thanks for sharing your solution here. Much appreciated!
Best Regards
Hi @DanielRamos ,
Please check if you hit any following limitation, you can find the details in this official documentation.
Best Regards
Hi @Anonymous
Thank you for your quick response.
Those settings were configured from beggining: my Service Principal is admin of Workspace, I'm sending the username and roles within the body of my http call to end point.
Interesting thing here is that when I remove any RLS from Dashboard in PowerBi Desktop and Publish, embedding successfully works.
Providing more detail, the app I'm deploying seems like uses the GenerateTokenInGroup Api
Is there any compatibility issue with RLS?
Thanks in advance
Hi @DanielRamos ,
Please check the following limitation when apply RLS, you can find the details in this official documentation.
Best Regards
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
6 | |
6 | |
3 | |
2 | |
2 |