<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Embedding Dashboard on Salesforce throws error when using RLS in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Embedding-Dashboard-on-Salesforce-throws-error-when-using-RLS/m-p/2907449#M39756</link>
    <description>&lt;P&gt;Please, help.&lt;/P&gt;&lt;P&gt;I'm using&amp;nbsp;&lt;A href="https://github.com/PowerBiDevCamp/SalesforceAppOwnsDataEmbedding" target="_blank" rel="noopener"&gt;SalesforceAppOwnsDataEmbedding&lt;/A&gt;&amp;nbsp;to display a Dashboard in Salesforce, everything works well, inclusively I'm able to send Report Level Filters.&lt;/P&gt;&lt;P&gt;However, if &lt;STRONG&gt;Row Level Security&lt;/STRONG&gt; is used in Dashboard, then error occurs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(Displayed error) Generate Token Error: OK&lt;BR /&gt;(Internal Error) Bad Request, Error 400&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I already tried using identities for api body with no success.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not sure if App Registration in Azure requires specific permission over the PowerBi Service Api. (read/write)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Class method where error occurs:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// 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);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 15 Nov 2022 18:26:16 GMT</pubDate>
    <dc:creator>DanielRamos</dc:creator>
    <dc:date>2022-11-15T18:26:16Z</dc:date>
    <item>
      <title>Embedding Dashboard on Salesforce throws error when using RLS</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Embedding-Dashboard-on-Salesforce-throws-error-when-using-RLS/m-p/2907449#M39756</link>
      <description>&lt;P&gt;Please, help.&lt;/P&gt;&lt;P&gt;I'm using&amp;nbsp;&lt;A href="https://github.com/PowerBiDevCamp/SalesforceAppOwnsDataEmbedding" target="_blank" rel="noopener"&gt;SalesforceAppOwnsDataEmbedding&lt;/A&gt;&amp;nbsp;to display a Dashboard in Salesforce, everything works well, inclusively I'm able to send Report Level Filters.&lt;/P&gt;&lt;P&gt;However, if &lt;STRONG&gt;Row Level Security&lt;/STRONG&gt; is used in Dashboard, then error occurs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(Displayed error) Generate Token Error: OK&lt;BR /&gt;(Internal Error) Bad Request, Error 400&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I already tried using identities for api body with no success.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not sure if App Registration in Azure requires specific permission over the PowerBi Service Api. (read/write)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Class method where error occurs:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// 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);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Nov 2022 18:26:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Embedding-Dashboard-on-Salesforce-throws-error-when-using-RLS/m-p/2907449#M39756</guid>
      <dc:creator>DanielRamos</dc:creator>
      <dc:date>2022-11-15T18:26:16Z</dc:date>
    </item>
    <item>
      <title>Re: Embedding Dashboard on Salesforce throws error when using RLS</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Embedding-Dashboard-on-Salesforce-throws-error-when-using-RLS/m-p/2908474#M39766</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/435363"&gt;@DanielRamos&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Please check if you hit any following limitation, you can find the details in &lt;A href="https://learn.microsoft.com/en-us/power-bi/developer/embedded/cloud-rls?source=recommendations#considerations-and-limitations" target="_self"&gt;this official documentation&lt;/A&gt;.&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;The user that generates the embed token has to be a&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;member&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;or&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;admin&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;in both workspaces (the dataset workspace and the report workspace).&lt;/LI&gt;
&lt;LI&gt;When&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://learn.microsoft.com/en-us/power-bi/developer/embedded/generate-embed-token" data-linktype="relative-path" target="_blank"&gt;generating the embed token&lt;/A&gt;, you need to provide a username and a role. If you don't, one of the following will occur, depending on if the token is being generated by service principal or master user:
&lt;UL&gt;
&lt;LI&gt;For a&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;service principal&lt;/STRONG&gt;, token generation will fail.&lt;/LI&gt;
&lt;LI&gt;For a&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;master user&lt;/STRONG&gt;, token generation will succeed but the data will not be filtered (all the data is returned).&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Wed, 16 Nov 2022 06:50:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Embedding-Dashboard-on-Salesforce-throws-error-when-using-RLS/m-p/2908474#M39766</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-11-16T06:50:24Z</dc:date>
    </item>
    <item>
      <title>Re: Embedding Dashboard on Salesforce throws error when using RLS</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Embedding-Dashboard-on-Salesforce-throws-error-when-using-RLS/m-p/2913737#M39807</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your quick response.&lt;/P&gt;&lt;P&gt;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.&lt;BR /&gt;&lt;BR /&gt;Interesting thing here is that when I remove any RLS from Dashboard in PowerBi Desktop and Publish, embedding successfully works.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Providing more detail, the app I'm deploying seems like uses the &lt;STRONG&gt;GenerateTokenInGroup&lt;/STRONG&gt; Api&lt;/P&gt;&lt;P&gt;Is there any compatibility issue with RLS?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2022 20:28:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Embedding-Dashboard-on-Salesforce-throws-error-when-using-RLS/m-p/2913737#M39807</guid>
      <dc:creator>DanielRamos</dc:creator>
      <dc:date>2022-11-17T20:28:26Z</dc:date>
    </item>
    <item>
      <title>Re: Embedding Dashboard on Salesforce throws error when using RLS</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Embedding-Dashboard-on-Salesforce-throws-error-when-using-RLS/m-p/2920671#M39877</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/435363"&gt;@DanielRamos&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Please check the following limitation when apply RLS,&amp;nbsp; you can find the details in &lt;A href="https://learn.microsoft.com/en-us/power-bi/enterprise/service-admin-rls#considerations-and-limitations" target="_self"&gt;this official documentation&lt;/A&gt;.&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Service principals cannot be added to an RLS role. Accordingly, RLS won’t be applied for apps using a service principal as the final effective identity.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Tue, 22 Nov 2022 07:08:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Embedding-Dashboard-on-Salesforce-throws-error-when-using-RLS/m-p/2920671#M39877</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-11-22T07:08:39Z</dc:date>
    </item>
    <item>
      <title>Re: Embedding Dashboard on Salesforce throws error when using RLS</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Embedding-Dashboard-on-Salesforce-throws-error-when-using-RLS/m-p/2922304#M39893</link>
      <description>&lt;P&gt;Finally achieved this embedding!!!&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":party_popper:"&gt;🎉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Sharing solution in case someone's struggling with something similar.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Important!&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Now I included Content-Type: application/json to the header of request&lt;/LI&gt;&lt;LI&gt;Request Body is now composed with accessLevel: View, and identities using Service Principal Id (Application Client Id) as the username.&lt;/LI&gt;&lt;LI&gt;I created a new Role with no filters and assigned to Service Principal&lt;UL&gt;&lt;LI&gt;(This allows me to apply ReportLevelFilters for dynamically filtering from Salesforce)&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;Provided the required API permissions on App Registration (Service Principal) on Azure.&lt;UL&gt;&lt;LI&gt;Delegated Permissions, Power Bi Service;&amp;nbsp;Report.ReadWrite.All, Dataset.ReadWrite.All, Content.Create&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Full HttpRequest code&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// 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);
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Response code is now 200 and Token is successfully generated,&lt;/P&gt;&lt;P&gt;Dashboard is displaying and filtering is correctly applying.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hooray!&lt;/P&gt;</description>
      <pubDate>Tue, 22 Nov 2022 16:56:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Embedding-Dashboard-on-Salesforce-throws-error-when-using-RLS/m-p/2922304#M39893</guid>
      <dc:creator>DanielRamos</dc:creator>
      <dc:date>2022-11-22T16:56:46Z</dc:date>
    </item>
    <item>
      <title>Re: Embedding Dashboard on Salesforce throws error when using RLS</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Embedding-Dashboard-on-Salesforce-throws-error-when-using-RLS/m-p/2922933#M39899</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/435363"&gt;@DanielRamos&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;It's glad to hear that your problem has been resolved. And thanks for sharing your solution here. Much appreciated!&lt;/P&gt;
&lt;P&gt;Best Regards&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Nov 2022 00:49:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Embedding-Dashboard-on-Salesforce-throws-error-when-using-RLS/m-p/2922933#M39899</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-11-23T00:49:06Z</dc:date>
    </item>
  </channel>
</rss>

