Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
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
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
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
12 | |
2 | |
2 | |
1 | |
1 |