<?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 GET Embed Token REST API is returning 400 Error in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/GET-Embed-Token-REST-API-is-returning-400-Error/m-p/3675761#M49298</link>
    <description>&lt;P&gt;I am trying to integrate powerbi reports into salesforce using app own data embedding. Below is the apex code which makes GET REST API call to powerbi to recieve embed token. The same code is retreieving embed token for paginated report but not for powerBIreport. I get 400 /Bad Request error when i try to generate embed token for powerBIreport.&lt;/P&gt;&lt;P&gt;Please help and thanks in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// Call to Power BI Service API to get embed token for report&lt;BR /&gt;HttpRequest reqGetEmbedToken = new HttpRequest();&lt;BR /&gt;reqGetEmbedToken.setMethod('POST');&lt;BR /&gt;String urlGetEmbedToken = '&lt;A href="https://api.powerbi.com/v1.0/myorg/groups/" target="_blank" rel="noopener"&gt;https://api.powerbi.com/v1.0/myorg/groups/&lt;/A&gt;' + WorkspaceId + '/reports/' + ReportId + '/GenerateToken';&lt;BR /&gt;reqGetEmbedToken.setEndpoint(urlGetEmbedToken);&lt;BR /&gt;reqGetEmbedToken.setHeader('Authorization', 'Bearer ' + access_token);&lt;BR /&gt;reqGetEmbedToken.setBody('{"accessLevel": "View", "datasetId": "' + powerBiReport.datasetId + '"}');&lt;BR /&gt;&lt;BR /&gt;HttpResponse responseEmbedToken = http.send(reqGetEmbedToken);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// check response for success&lt;BR /&gt;if(responseEmbedToken.getStatusCode()!=200){&lt;BR /&gt;System.debug('ERROR --- Getting Embed Token --- ERROR');&lt;BR /&gt;System.debug('Status Code: ' + responseEmbedToken.getStatusCode());&lt;BR /&gt;PowerBiReportData getEmbedTokenError = new PowerBiReportData();&lt;BR /&gt;getEmbedTokenError.error = 'Get Embed Token Error: ' + response.getStatus();&lt;BR /&gt;return getEmbedTokenError;&lt;BR /&gt;}&lt;/P&gt;</description>
    <pubDate>Fri, 02 Feb 2024 14:21:32 GMT</pubDate>
    <dc:creator>nikitha</dc:creator>
    <dc:date>2024-02-02T14:21:32Z</dc:date>
    <item>
      <title>GET Embed Token REST API is returning 400 Error</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/GET-Embed-Token-REST-API-is-returning-400-Error/m-p/3675761#M49298</link>
      <description>&lt;P&gt;I am trying to integrate powerbi reports into salesforce using app own data embedding. Below is the apex code which makes GET REST API call to powerbi to recieve embed token. The same code is retreieving embed token for paginated report but not for powerBIreport. I get 400 /Bad Request error when i try to generate embed token for powerBIreport.&lt;/P&gt;&lt;P&gt;Please help and thanks in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// Call to Power BI Service API to get embed token for report&lt;BR /&gt;HttpRequest reqGetEmbedToken = new HttpRequest();&lt;BR /&gt;reqGetEmbedToken.setMethod('POST');&lt;BR /&gt;String urlGetEmbedToken = '&lt;A href="https://api.powerbi.com/v1.0/myorg/groups/" target="_blank" rel="noopener"&gt;https://api.powerbi.com/v1.0/myorg/groups/&lt;/A&gt;' + WorkspaceId + '/reports/' + ReportId + '/GenerateToken';&lt;BR /&gt;reqGetEmbedToken.setEndpoint(urlGetEmbedToken);&lt;BR /&gt;reqGetEmbedToken.setHeader('Authorization', 'Bearer ' + access_token);&lt;BR /&gt;reqGetEmbedToken.setBody('{"accessLevel": "View", "datasetId": "' + powerBiReport.datasetId + '"}');&lt;BR /&gt;&lt;BR /&gt;HttpResponse responseEmbedToken = http.send(reqGetEmbedToken);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// check response for success&lt;BR /&gt;if(responseEmbedToken.getStatusCode()!=200){&lt;BR /&gt;System.debug('ERROR --- Getting Embed Token --- ERROR');&lt;BR /&gt;System.debug('Status Code: ' + responseEmbedToken.getStatusCode());&lt;BR /&gt;PowerBiReportData getEmbedTokenError = new PowerBiReportData();&lt;BR /&gt;getEmbedTokenError.error = 'Get Embed Token Error: ' + response.getStatus();&lt;BR /&gt;return getEmbedTokenError;&lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2024 14:21:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/GET-Embed-Token-REST-API-is-returning-400-Error/m-p/3675761#M49298</guid>
      <dc:creator>nikitha</dc:creator>
      <dc:date>2024-02-02T14:21:32Z</dc:date>
    </item>
    <item>
      <title>Re: GET Embed Token REST API is returning 400 Error</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/GET-Embed-Token-REST-API-is-returning-400-Error/m-p/3678327#M49322</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/684276"&gt;@nikitha&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There could be multiple reasons for the error. Usually the response body has additional info, you can try to see if it helps understanding the reason.&lt;/P&gt;&lt;P&gt;datasetId isn't mandatory in the request body since you ask for accessLevel "View" and not "Create", but I doubt it's the reason for the failure.&lt;/P&gt;</description>
      <pubDate>Sun, 04 Feb 2024 08:28:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/GET-Embed-Token-REST-API-is-returning-400-Error/m-p/3678327#M49322</guid>
      <dc:creator>AmosHersch</dc:creator>
      <dc:date>2024-02-04T08:28:23Z</dc:date>
    </item>
  </channel>
</rss>

