<?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 Re: Error:500 BadRequest when trying to get embed token of new reports in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Error-500-BadRequest-when-trying-to-get-embed-token-of-new/m-p/1018398#M23028</link>
    <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a similar issue in my production environment. Everything seems to be working correctly on my localhost, but when I moved to prod I don't receive the embed token.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Did you solve this? How did you do it?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 09 Apr 2020 21:07:51 GMT</pubDate>
    <dc:creator>alopez1205</dc:creator>
    <dc:date>2020-04-09T21:07:51Z</dc:date>
    <item>
      <title>Error:500 BadRequest when trying to get embed token of new reports</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Error-500-BadRequest-when-trying-to-get-embed-token-of-new/m-p/874810#M21722</link>
      <description>&lt;P&gt;I created an asp.net api that uses Service Principal to connect to AAD and generate embed tokens, and sends that token to my frontend. It is working well when I use old reports that some of my colleages published last summer, however, we are trying to use Azure Analysis Services and created some new reports to test it.&lt;/P&gt;&lt;P&gt;The api isn't able to generate the embed tokens for these new reports, throwing instead a BadRequest 500. Also while I was figuring out RLS I published another report from a sample given by Microsoft and the same BadRequest happens for the sample report. Are we forgetting some kind of configuration needed to generate tokens? I understand the erros with the reports using AAS but the one I published does not use it afaik.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;private static readonly string Tenant = "tenant";&lt;BR /&gt;private static readonly string AppId = "id";&lt;BR /&gt;private static readonly string AppSecret = "secret";&lt;BR /&gt;private static readonly string Resource = "&lt;A href="https://analysis.windows.net/powerbi/api" target="_blank"&gt;https://analysis.windows.net/powerbi/api&lt;/A&gt;";&lt;/P&gt;&lt;P&gt;private string getToken()&lt;BR /&gt;{&lt;BR /&gt;var authContext = new AuthenticationContext(Tenant);&lt;BR /&gt;var clientCredential = new ClientCredential(AppId, AppSecret);&lt;BR /&gt;return authContext.AcquireTokenAsync(Resource, clientCredential).Result.AccessToken;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;private PowerBIClient getPBIClient()&lt;BR /&gt;{&lt;BR /&gt;var token = new TokenCredentials(getToken(), "Bearer");&lt;BR /&gt;return new PowerBIClient(new Uri("&lt;A href="https://api.powerbi.com/" target="_blank"&gt;https://api.powerbi.com/&lt;/A&gt;"), token);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;public async Task&amp;lt;ODataResponseListReport&amp;gt; getReports(string ws)&lt;BR /&gt;{&lt;BR /&gt;PowerBIClient pbiClient = getPBIClient();&lt;/P&gt;&lt;P&gt;var reports = await pbiClient.Reports.GetReportsInGroupAsync(ws);&lt;BR /&gt;return reports;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;public async Task&amp;lt;ReportEmbeddingData&amp;gt; getReportEmbeddingData(string ws, string rep)&lt;BR /&gt;{&lt;BR /&gt;PowerBIClient pbiClient = getPBIClient();&lt;/P&gt;&lt;P&gt;var report = await pbiClient.Reports.GetReportInGroupAsync(ws, rep);&lt;BR /&gt;var embedUrl = report.EmbedUrl;&lt;BR /&gt;var reportName = report.Name;&lt;BR /&gt;GenerateTokenRequest genTokenReqParam = new GenerateTokenRequest(accessLevel: "view");&lt;BR /&gt;string embedToken = (await pbiClient.Reports.GenerateTokenInGroupAsync(ws, rep, genTokenReqParam)).Token;&lt;BR /&gt;return new ReportEmbeddingData&lt;BR /&gt;{&lt;BR /&gt;type = "report",&lt;BR /&gt;reportId = rep,&lt;BR /&gt;reportName = reportName,&lt;BR /&gt;embedUrl = embedUrl,&lt;BR /&gt;accessToken = embedToken&lt;BR /&gt;};&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Fri, 13 Dec 2019 15:22:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Error-500-BadRequest-when-trying-to-get-embed-token-of-new/m-p/874810#M21722</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-12-13T15:22:01Z</dc:date>
    </item>
    <item>
      <title>Re: Error:500 BadRequest when trying to get embed token of new reports</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Error-500-BadRequest-when-trying-to-get-embed-token-of-new/m-p/1018398#M23028</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a similar issue in my production environment. Everything seems to be working correctly on my localhost, but when I moved to prod I don't receive the embed token.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Did you solve this? How did you do it?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Apr 2020 21:07:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Error-500-BadRequest-when-trying-to-get-embed-token-of-new/m-p/1018398#M23028</guid>
      <dc:creator>alopez1205</dc:creator>
      <dc:date>2020-04-09T21:07:51Z</dc:date>
    </item>
  </channel>
</rss>

