<?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: System.AuraHandledException: Script-thrown exception while calling the Power BI REST API from ap in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/System-AuraHandledException-Script-thrown-exception-while/m-p/5277937#M65312</link>
    <description>&lt;P&gt;A &lt;STRONG&gt;401 Unauthorized&lt;/STRONG&gt; from the Power BI REST API almost always indicates that the access token is either invalid for the endpoint or doesn't contain the required permissions.&lt;/P&gt;&lt;P&gt;A few things to verify:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Endpoint&lt;/STRONG&gt;&lt;BR /&gt;The POST &lt;A href="https://api.powerbi.com/v1.0/myorg/GenerateToken" target="_blank" rel="noopener"&gt;https://api.powerbi.com/v1.0/myorg/GenerateToken&lt;/A&gt; endpoint is &lt;STRONG&gt;not&lt;/STRONG&gt; the standard endpoint for embedding reports. The endpoint depends on what you're trying to generate a token for.&lt;/P&gt;&lt;P&gt;For a report, the typical endpoint is:&lt;/P&gt;&lt;PRE&gt;POST https://api.powerbi.com/v1.0/myorg/groups/{groupId}/reports/{reportId}/GenerateToken&lt;/PRE&gt;&lt;P&gt;If you're using the top-level /GenerateToken endpoint, confirm that it matches your embedding scenario and API version.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Validate the access token&lt;/STRONG&gt;&lt;BR /&gt;Decode the Microsoft Entra ID access token (for example, using jwt.ms) and verify:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;aud = &lt;A href="https://analysis.windows.net/powerbi/api" target="_blank" rel="noopener"&gt;https://analysis.windows.net/powerbi/api&lt;/A&gt;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;The token hasn't expired.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;The token contains the required delegated scopes or application roles.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;API permissions&lt;/STRONG&gt;&lt;BR /&gt;Ensure your Microsoft Entra application has the appropriate Power BI API permissions (such as Report.Read.All, Dataset.Read.All, or Report.ReadWrite.All, depending on your scenario), and that admin consent has been granted where required.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Embedding prerequisites&lt;/STRONG&gt;&lt;BR /&gt;Verify that:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;The report exists.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;The workspace ID and report ID are correct.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;The authenticated user or service principal has access to the workspace.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;If using a service principal, ensure &lt;STRONG&gt;"Allow service principals to use Power BI APIs"&lt;/STRONG&gt; is enabled in the Power BI Admin Portal and that the service principal has been granted access to the workspace.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Capture the full response&lt;/STRONG&gt;&lt;BR /&gt;Even if response.getBody() is null in Apex, log:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;Response headers&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;WWW-Authenticate header (if present)&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Response status&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Correlation/Request IDs (ActivityId or RequestId)&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;These are extremely useful for diagnosing authentication failures with Microsoft support.&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;If you can share:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;Whether you're using a &lt;STRONG&gt;delegated user&lt;/STRONG&gt; or a &lt;STRONG&gt;service principal&lt;/STRONG&gt;,&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;The exact endpoint you're calling,&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;And how you're acquiring the Entra ID token,&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;it will be much easier to pinpoint the root cause.&lt;/P&gt;</description>
    <pubDate>Wed, 08 Jul 2026 04:38:54 GMT</pubDate>
    <dc:creator>Prince0011</dc:creator>
    <dc:date>2026-07-08T04:38:54Z</dc:date>
    <item>
      <title>System.AuraHandledException: Script-thrown exception while calling the Power BI REST API from apex</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/System-AuraHandledException-Script-thrown-exception-while/m-p/5275958#M65310</link>
      <description>&lt;P&gt;Hello Team,&lt;/P&gt;&lt;P&gt;I am integrating Salesforce with the Power BI REST API.&lt;/P&gt;&lt;P&gt;I have an Apex method named getPowerBiReportToken that receives a Microsoft Entra ID access token and uses it to call the following Power BI REST API endpoint:&lt;/P&gt;&lt;PRE&gt;POST https://api.powerbi.com/v1.0/myorg/GenerateToken&lt;/PRE&gt;&lt;P&gt;I am setting the Authorization header with the Bearer access token.&lt;/P&gt;&lt;P&gt;However, when the API is invoked:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;The HTTP status code returned is &lt;STRONG&gt;401 (Unauthorized)&lt;/STRONG&gt;.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;The response body is &lt;STRONG&gt;null&lt;/STRONG&gt;.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;The exception surfaced in Apex is:&lt;BR /&gt;System.AuraHandledException: Script-thrown exception&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Has anyone encountered this issue before?&lt;/P&gt;&lt;P&gt;Could you please help me understand:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;Is the endpoint I am using correct for generating a Power BI report token?&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;What could cause a &lt;STRONG&gt;401 Unauthorized&lt;/STRONG&gt; response with a &lt;STRONG&gt;null response body&lt;/STRONG&gt;?&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Are there any prerequisites or permissions that I should verify?&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Any guidance would be greatly appreciated.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jul 2026 09:53:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/System-AuraHandledException-Script-thrown-exception-while/m-p/5275958#M65310</guid>
      <dc:creator>YashMoroliya</dc:creator>
      <dc:date>2026-07-07T09:53:32Z</dc:date>
    </item>
    <item>
      <title>Re: System.AuraHandledException: Script-thrown exception while calling the Power BI REST API from ap</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/System-AuraHandledException-Script-thrown-exception-while/m-p/5277937#M65312</link>
      <description>&lt;P&gt;A &lt;STRONG&gt;401 Unauthorized&lt;/STRONG&gt; from the Power BI REST API almost always indicates that the access token is either invalid for the endpoint or doesn't contain the required permissions.&lt;/P&gt;&lt;P&gt;A few things to verify:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Endpoint&lt;/STRONG&gt;&lt;BR /&gt;The POST &lt;A href="https://api.powerbi.com/v1.0/myorg/GenerateToken" target="_blank" rel="noopener"&gt;https://api.powerbi.com/v1.0/myorg/GenerateToken&lt;/A&gt; endpoint is &lt;STRONG&gt;not&lt;/STRONG&gt; the standard endpoint for embedding reports. The endpoint depends on what you're trying to generate a token for.&lt;/P&gt;&lt;P&gt;For a report, the typical endpoint is:&lt;/P&gt;&lt;PRE&gt;POST https://api.powerbi.com/v1.0/myorg/groups/{groupId}/reports/{reportId}/GenerateToken&lt;/PRE&gt;&lt;P&gt;If you're using the top-level /GenerateToken endpoint, confirm that it matches your embedding scenario and API version.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Validate the access token&lt;/STRONG&gt;&lt;BR /&gt;Decode the Microsoft Entra ID access token (for example, using jwt.ms) and verify:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;aud = &lt;A href="https://analysis.windows.net/powerbi/api" target="_blank" rel="noopener"&gt;https://analysis.windows.net/powerbi/api&lt;/A&gt;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;The token hasn't expired.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;The token contains the required delegated scopes or application roles.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;API permissions&lt;/STRONG&gt;&lt;BR /&gt;Ensure your Microsoft Entra application has the appropriate Power BI API permissions (such as Report.Read.All, Dataset.Read.All, or Report.ReadWrite.All, depending on your scenario), and that admin consent has been granted where required.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Embedding prerequisites&lt;/STRONG&gt;&lt;BR /&gt;Verify that:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;The report exists.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;The workspace ID and report ID are correct.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;The authenticated user or service principal has access to the workspace.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;If using a service principal, ensure &lt;STRONG&gt;"Allow service principals to use Power BI APIs"&lt;/STRONG&gt; is enabled in the Power BI Admin Portal and that the service principal has been granted access to the workspace.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Capture the full response&lt;/STRONG&gt;&lt;BR /&gt;Even if response.getBody() is null in Apex, log:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;Response headers&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;WWW-Authenticate header (if present)&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Response status&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Correlation/Request IDs (ActivityId or RequestId)&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;These are extremely useful for diagnosing authentication failures with Microsoft support.&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;If you can share:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;Whether you're using a &lt;STRONG&gt;delegated user&lt;/STRONG&gt; or a &lt;STRONG&gt;service principal&lt;/STRONG&gt;,&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;The exact endpoint you're calling,&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;And how you're acquiring the Entra ID token,&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;it will be much easier to pinpoint the root cause.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jul 2026 04:38:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/System-AuraHandledException-Script-thrown-exception-while/m-p/5277937#M65312</guid>
      <dc:creator>Prince0011</dc:creator>
      <dc:date>2026-07-08T04:38:54Z</dc:date>
    </item>
    <item>
      <title>Re: System.AuraHandledException: Script-thrown exception while calling the Power BI REST API from ap</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/System-AuraHandledException-Script-thrown-exception-while/m-p/5284069#M65323</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/1633533"&gt;@YashMoroliya&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We wanted to follow up and check whether you've had a chance to review the solutions shared by &lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/1603209"&gt;@Prince0011&lt;/a&gt;&amp;nbsp;regarding your issue. We hope the information provided helps address your query.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Should you have any further questions, please feel free to reach out to the Microsoft Fabric Community we're always happy to help.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;BR /&gt;Srikanth Cheri&lt;BR /&gt;CST team.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jul 2026 13:09:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/System-AuraHandledException-Script-thrown-exception-while/m-p/5284069#M65323</guid>
      <dc:creator>v-csrikanth</dc:creator>
      <dc:date>2026-07-10T13:09:06Z</dc:date>
    </item>
    <item>
      <title>Re: System.AuraHandledException: Script-thrown exception while calling the Power BI REST API from ap</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/System-AuraHandledException-Script-thrown-exception-while/m-p/5293845#M65339</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/1633533"&gt;@YashMoroliya&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=""&gt;We would like to inquire whether have you got the chance to check the solutions provided by&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/1603209"&gt;@Prince0011&lt;/a&gt;&amp;nbsp; in commiunity to resolve the issue. We hope the information provided helps to clear the query. Should you have any further queries, kindly feel free to contact the Microsoft Fabric community.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=""&gt;&lt;BR /&gt;Thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jul 2026 13:15:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/System-AuraHandledException-Script-thrown-exception-while/m-p/5293845#M65339</guid>
      <dc:creator>v-csrikanth</dc:creator>
      <dc:date>2026-07-14T13:15:43Z</dc:date>
    </item>
  </channel>
</rss>

