<?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: Get File Of Export To File In Group - NodeJS / React in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Get-File-Of-Export-To-File-In-Group-NodeJS-React/m-p/3846419#M51802</link>
    <description>&lt;P&gt;Thank you very much. The response.buffer was the part I was missing. I appreciate the help.&lt;/P&gt;</description>
    <pubDate>Wed, 17 Apr 2024 17:25:57 GMT</pubDate>
    <dc:creator>trpeel</dc:creator>
    <dc:date>2024-04-17T17:25:57Z</dc:date>
    <item>
      <title>Get File Of Export To File In Group - NodeJS / React</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Get-File-Of-Export-To-File-In-Group-NodeJS-React/m-p/3839762#M51759</link>
      <description>&lt;P&gt;Hello. I am trying to figure out how to stream/download the exported PDF file from a Power BI API Export call. I'm using a NodeJS backend with a React frontend. Here's what I'm trying to do in the backend:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const queryResults = await fetch(`https://api.powerbi.com/v1.0/myorg/groups/${workspaceId}/reports/${reportId}/exports/${exportId}/file`, {
      method: 'GET',
      headers: {
        'content-type': 'application/pdf',
        authorization: `Bearer ${(await getAccessToken()).accessToken}`
      }
    });

    return queryResults;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;For reference:&amp;nbsp;&lt;A href="https://learn.microsoft.com/en-us/rest/api/power-bi/reports/get-file-of-export-to-file-in-group" target="_blank" rel="noopener"&gt;https://learn.microsoft.com/en-us/rest/api/power-bi/reports/get-file-of-export-to-file-in-group&lt;/A&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;All I get is a JSON response of { size: 0, timeout: 0}. I've found some C# samples online for streaming the PDF file back to the browser, but nothing for NodeJS. Any help would be appreciated.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thanks.&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 16 Apr 2024 04:24:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Get-File-Of-Export-To-File-In-Group-NodeJS-React/m-p/3839762#M51759</guid>
      <dc:creator>trpeel</dc:creator>
      <dc:date>2024-04-16T04:24:58Z</dc:date>
    </item>
    <item>
      <title>Re: Get File Of Export To File In Group - NodeJS / React</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Get-File-Of-Export-To-File-In-Group-NodeJS-React/m-p/3844666#M51793</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/250508"&gt;@trpeel&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;It sounds like you are trying to download a PDF file that has been exported from a Power BI report using the Power BI API. However, it return size 0. The possible reason is&amp;nbsp;the API call is not correctly authenticated. Please update the code as below and check if it can return the expected result...&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;const fetch = require('node-fetch');
const workspaceId = '&amp;lt;your workspace ID&amp;gt;';
const reportId = '&amp;lt;your report ID&amp;gt;';
const exportId = '&amp;lt;your export ID&amp;gt;';
const accessToken = '&amp;lt;your access token&amp;gt;';
const url = `https://api.powerbi.com/v1.0/myorg/groups/${workspaceId}/reports/${reportId}/exports/${exportId}/file`;
const options = {
  method: 'GET',
  headers: {
    'Content-Type': 'application/pdf',
    'Authorization': `Bearer ${accessToken}`
  }
};
fetch(url, options)
  .then(response =&amp;gt; {
    if (!response.ok) {
      throw new Error(`HTTP error ${response.status}`);
    }
    return response.buffer();
  })
  .then(buffer =&amp;gt; {
    // Do something with the PDF buffer, such as write it to a file or send it to the client
  })
  .catch(error =&amp;gt; {
    console.error(error);
  });&lt;/LI-CODE&gt;
&lt;P&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Wed, 17 Apr 2024 08:42:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Get-File-Of-Export-To-File-In-Group-NodeJS-React/m-p/3844666#M51793</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-04-17T08:42:19Z</dc:date>
    </item>
    <item>
      <title>Re: Get File Of Export To File In Group - NodeJS / React</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Get-File-Of-Export-To-File-In-Group-NodeJS-React/m-p/3846419#M51802</link>
      <description>&lt;P&gt;Thank you very much. The response.buffer was the part I was missing. I appreciate the help.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Apr 2024 17:25:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Get-File-Of-Export-To-File-In-Group-NodeJS-React/m-p/3846419#M51802</guid>
      <dc:creator>trpeel</dc:creator>
      <dc:date>2024-04-17T17:25:57Z</dc:date>
    </item>
  </channel>
</rss>

