<?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 Getting error when calling Power BI API Operation returned an invalid status code 'Forbidden' in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Getting-error-when-calling-Power-BI-API-Operation-returned-an/m-p/3201431#M42338</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using Power BI c# SDK to export Power BI report in PDF. I am getting error as "&lt;STRONG&gt;Operation returned an invalid status code 'Forbidden'&lt;/STRONG&gt;".&amp;nbsp; I have setup app registration in Azure Active Directory and assigned the required permissions. I am using Power BI PRO license.&lt;/P&gt;&lt;P&gt;Below is the code:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;IConfidentialClientApplication app = ConfidentialClientApplicationBuilder&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;.Create(clientId)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;.WithClientSecret(clientSecret)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;.WithAuthority(new Uri(authority))&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;.Build();&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;string[] scopes = new string[] { $"{resource}/.default" };&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;AuthenticationResult result = null;&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;result = app.AcquireTokenForClient(scopes).ExecuteAsync().Result;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;var tokenCredentials = new TokenCredentials(result.AccessToken, "Bearer");&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;var client = new PowerBIClient(new Uri("&lt;A href="https://api.powerbi.com" target="_blank" rel="noopener"&gt;https://api.powerbi.com&lt;/A&gt;"), tokenCredentials);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;EM&gt;FileFormat ExportFileFormat = FileFormat.PDF;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;List&amp;lt;ExportFilter&amp;gt; eFilter = new List&amp;lt;ExportFilter&amp;gt;() {&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;new ExportFilter { Filter = "xxxxx=xxxxxx" }&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;};&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;var options = new ExportReportRequest&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;{&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Format = ExportFileFormat&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;};&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Guid ReportID = new Guid("xxxxxxx");&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;var exportResult = client.Reports.ExportToFile(ReportID, options);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 23 Apr 2023 10:41:40 GMT</pubDate>
    <dc:creator>rajeshlohar1974</dc:creator>
    <dc:date>2023-04-23T10:41:40Z</dc:date>
    <item>
      <title>Getting error when calling Power BI API Operation returned an invalid status code 'Forbidden'</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Getting-error-when-calling-Power-BI-API-Operation-returned-an/m-p/3201431#M42338</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using Power BI c# SDK to export Power BI report in PDF. I am getting error as "&lt;STRONG&gt;Operation returned an invalid status code 'Forbidden'&lt;/STRONG&gt;".&amp;nbsp; I have setup app registration in Azure Active Directory and assigned the required permissions. I am using Power BI PRO license.&lt;/P&gt;&lt;P&gt;Below is the code:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;IConfidentialClientApplication app = ConfidentialClientApplicationBuilder&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;.Create(clientId)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;.WithClientSecret(clientSecret)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;.WithAuthority(new Uri(authority))&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;.Build();&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;string[] scopes = new string[] { $"{resource}/.default" };&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;AuthenticationResult result = null;&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;result = app.AcquireTokenForClient(scopes).ExecuteAsync().Result;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;var tokenCredentials = new TokenCredentials(result.AccessToken, "Bearer");&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;var client = new PowerBIClient(new Uri("&lt;A href="https://api.powerbi.com" target="_blank" rel="noopener"&gt;https://api.powerbi.com&lt;/A&gt;"), tokenCredentials);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;EM&gt;FileFormat ExportFileFormat = FileFormat.PDF;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;List&amp;lt;ExportFilter&amp;gt; eFilter = new List&amp;lt;ExportFilter&amp;gt;() {&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;new ExportFilter { Filter = "xxxxx=xxxxxx" }&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;};&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;var options = new ExportReportRequest&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;{&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Format = ExportFileFormat&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;};&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Guid ReportID = new Guid("xxxxxxx");&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;var exportResult = client.Reports.ExportToFile(ReportID, options);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 23 Apr 2023 10:41:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Getting-error-when-calling-Power-BI-API-Operation-returned-an/m-p/3201431#M42338</guid>
      <dc:creator>rajeshlohar1974</dc:creator>
      <dc:date>2023-04-23T10:41:40Z</dc:date>
    </item>
    <item>
      <title>Re: Getting error when calling Power BI API Operation returned an invalid status code 'Forbidden'</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Getting-error-when-calling-Power-BI-API-Operation-returned-an/m-p/3203435#M42356</link>
      <description>&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/550217"&gt;@rajeshlohar1974&lt;/a&gt;&amp;nbsp;Reports can only be exported with REST API if you have Premium of Azure capacity.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2023 17:12:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Getting-error-when-calling-Power-BI-API-Operation-returned-an/m-p/3203435#M42356</guid>
      <dc:creator>AntrikshSharma</dc:creator>
      <dc:date>2023-04-24T17:12:36Z</dc:date>
    </item>
  </channel>
</rss>

