<?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 Operation returned an invalid status code 'BadRequest' in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Operation-returned-an-invalid-status-code-BadRequest/m-p/2691400#M37815</link>
    <description>&lt;P&gt;I tried to use RLS with PowerBi embedded analytics. I followed steps from&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.microsoft.com/en-us/power-bi/developer/embedded/embedded-row-level-security" target="_blank" rel="noopener"&gt;Using row-level security with embedded content in Power BI embedded analytics - Power BI | Microsoft Docs&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;This is my code to generate tokens:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;public EmbedToken GetEmbedToken(Guid reportId, IList&amp;lt;Guid&amp;gt; datasetIds, [Optional] Guid targetWorkspaceId)&lt;/P&gt;&lt;P&gt;PowerBIClient pbiClient = this.GetPowerBIClient();&lt;/P&gt;&lt;P&gt;// Create a request for getting Embed token&lt;BR /&gt;// This method works only with new Power BI V2 workspace experience&lt;BR /&gt;var tokenRequest = new GenerateTokenRequestV2(&lt;/P&gt;&lt;P&gt;reports: new List&amp;lt;GenerateTokenRequestV2Report&amp;gt;() { new GenerateTokenRequestV2Report(reportId) },&lt;/P&gt;&lt;P&gt;datasets: datasetIds.Select(datasetId =&amp;gt; new GenerateTokenRequestV2Dataset(datasetId.ToString())).ToList(),&lt;/P&gt;&lt;P&gt;targetWorkspaces: targetWorkspaceId != Guid.Empty ? new List&amp;lt;GenerateTokenRequestV2TargetWorkspace&amp;gt;() { new GenerateTokenRequestV2TargetWorkspace(targetWorkspaceId) } : null,&lt;BR /&gt;&lt;STRONG&gt;identities: new List&amp;lt;EffectiveIdentity&amp;gt; { { new EffectiveIdentity(username: "*****", roles: new List&amp;lt;string&amp;gt; { "***" }, datasets: new List&amp;lt;string&amp;gt; { datasetIds.ToString() }) } }); ;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;// Generate Embed token&lt;BR /&gt;var embedToken = pbiClient.EmbedToken.GenerateToken(tokenRequest);&lt;/P&gt;&lt;P&gt;return embedToken;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;But I get the following error&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PBIuser2010_0-1660105343401.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/762843iD27A3423BFEA2343/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PBIuser2010_0-1660105343401.png" alt="PBIuser2010_0-1660105343401.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 10 Aug 2022 04:27:52 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2022-08-10T04:27:52Z</dc:date>
    <item>
      <title>Operation returned an invalid status code 'BadRequest'</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Operation-returned-an-invalid-status-code-BadRequest/m-p/2691400#M37815</link>
      <description>&lt;P&gt;I tried to use RLS with PowerBi embedded analytics. I followed steps from&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.microsoft.com/en-us/power-bi/developer/embedded/embedded-row-level-security" target="_blank" rel="noopener"&gt;Using row-level security with embedded content in Power BI embedded analytics - Power BI | Microsoft Docs&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;This is my code to generate tokens:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;public EmbedToken GetEmbedToken(Guid reportId, IList&amp;lt;Guid&amp;gt; datasetIds, [Optional] Guid targetWorkspaceId)&lt;/P&gt;&lt;P&gt;PowerBIClient pbiClient = this.GetPowerBIClient();&lt;/P&gt;&lt;P&gt;// Create a request for getting Embed token&lt;BR /&gt;// This method works only with new Power BI V2 workspace experience&lt;BR /&gt;var tokenRequest = new GenerateTokenRequestV2(&lt;/P&gt;&lt;P&gt;reports: new List&amp;lt;GenerateTokenRequestV2Report&amp;gt;() { new GenerateTokenRequestV2Report(reportId) },&lt;/P&gt;&lt;P&gt;datasets: datasetIds.Select(datasetId =&amp;gt; new GenerateTokenRequestV2Dataset(datasetId.ToString())).ToList(),&lt;/P&gt;&lt;P&gt;targetWorkspaces: targetWorkspaceId != Guid.Empty ? new List&amp;lt;GenerateTokenRequestV2TargetWorkspace&amp;gt;() { new GenerateTokenRequestV2TargetWorkspace(targetWorkspaceId) } : null,&lt;BR /&gt;&lt;STRONG&gt;identities: new List&amp;lt;EffectiveIdentity&amp;gt; { { new EffectiveIdentity(username: "*****", roles: new List&amp;lt;string&amp;gt; { "***" }, datasets: new List&amp;lt;string&amp;gt; { datasetIds.ToString() }) } }); ;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;// Generate Embed token&lt;BR /&gt;var embedToken = pbiClient.EmbedToken.GenerateToken(tokenRequest);&lt;/P&gt;&lt;P&gt;return embedToken;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;But I get the following error&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PBIuser2010_0-1660105343401.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/762843iD27A3423BFEA2343/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PBIuser2010_0-1660105343401.png" alt="PBIuser2010_0-1660105343401.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Aug 2022 04:27:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Operation-returned-an-invalid-status-code-BadRequest/m-p/2691400#M37815</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-08-10T04:27:52Z</dc:date>
    </item>
    <item>
      <title>Re: Operation returned an invalid status code 'BadRequest'</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Operation-returned-an-invalid-status-code-BadRequest/m-p/2702031#M37897</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;Please check whether the parameters like report id/dataset id in your code are correct.&lt;/P&gt;
&lt;P&gt;I think you can try to post a Rest API to generate a Embed token for the report with RLS.&lt;/P&gt;
&lt;P&gt;For refernece:&amp;nbsp;&amp;nbsp;&lt;A href="https://docs.microsoft.com/en-us/rest/api/power-bi/embed-token/generate-token#example-of-generating-an-embed-token-for-a-paginated-report-which-has-a-power-bi-dataset-as-a-datasource.-the-id-of-the-dataset-must-be-specified-in-the-request.-the-report-and-dataset-can-each-have-its-own-identity" target="_blank"&gt;Embed Token - Generate Token - REST API (Power BI Power BI REST APIs) | Microsoft Docs&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Here is a solved post with similar issue like yours, I think you may refer to it to learn more details.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/Developer/Power-BI-send-invalid-status-code-Bad-Request-for-a-cached/m-p/612585" target="_blank"&gt;Solved: Re: Power BI send “invalid status code 'Bad Reques... - Microsoft Power BI Community&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Rico Zhou&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2022 06:32:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Operation-returned-an-invalid-status-code-BadRequest/m-p/2702031#M37897</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-08-16T06:32:30Z</dc:date>
    </item>
  </channel>
</rss>

