<?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: Exporting report to PDF using REST API returns blank file in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Exporting-report-to-PDF-using-REST-API-returns-blank-file/m-p/3449056#M44690</link>
    <description>&lt;P&gt;Seems like that didn't work as well. For some reason, I wasn't able to send the PDF file as attachment to email using Power Automate, but Exporting to a PDF file generated some output like:&lt;/P&gt;&lt;PRE&gt;{"statusCode":200,.......,"body":{"$content-type":"application/pdf","$content":"JVBERi0xLjc............"}&lt;/PRE&gt;&lt;P&gt;I just tried to save the decoded $content to a .PDF file manually, but that didn't work.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 27 Sep 2023 06:27:49 GMT</pubDate>
    <dc:creator>pej</dc:creator>
    <dc:date>2023-09-27T06:27:49Z</dc:date>
    <item>
      <title>Exporting report to PDF using REST API returns blank file</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Exporting-report-to-PDF-using-REST-API-returns-blank-file/m-p/3445990#M44658</link>
      <description>&lt;P&gt;Hello guys,&lt;/P&gt;&lt;P&gt;I'm trying to export a paginated report to PDF file using Power BI REST API. My account is currently in free trial, but I've created&amp;nbsp;&lt;STRONG&gt;Premium Per User&amp;nbsp;&lt;/STRONG&gt;workspace, where I have my Paginated Report:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="pej_0-1695647023718.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/973033i6D40082029536812/image-size/medium?v=v2&amp;amp;px=400" role="button" title="pej_0-1695647023718.png" alt="pej_0-1695647023718.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I'm calling these API endpoints:&lt;/P&gt;&lt;P&gt;1. &lt;A href="https://learn.microsoft.com/en-us/rest/api/power-bi/reports/export-to-file" target="_self"&gt;Export To File&lt;/A&gt; (to initialize exporting)&lt;/P&gt;&lt;P&gt;2. &lt;A href="https://learn.microsoft.com/en-us/rest/api/power-bi/reports/get-export-to-file-status" target="_self"&gt;Get Export To File Status&lt;/A&gt; (for polling status)&lt;/P&gt;&lt;P&gt;3. &lt;A href="https://learn.microsoft.com/en-us/rest/api/power-bi/reports/get-file-of-export-to-file" target="_self"&gt;Get File Of Export To File&lt;/A&gt; (retrieve the file)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I try to export .PDF file, I get just blank pages. However, when I tried to export to simple .CSV, it works. Also tried .PPTX and when trying to open file it says it's corrupted.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to also read through &lt;A href="https://learn.microsoft.com/en-us/power-bi/developer/embedded/export-paginated-report#considerations-and-limitations" target="_self"&gt;consideration and limitations for exporting paginated reports&lt;/A&gt;, but that wasn't that much helpful and it doesn't explain why the CSV would work and PDF not.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help will be appreciated. Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 25 Sep 2023 13:20:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Exporting-report-to-PDF-using-REST-API-returns-blank-file/m-p/3445990#M44658</guid>
      <dc:creator>pej</dc:creator>
      <dc:date>2023-09-25T13:20:49Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting report to PDF using REST API returns blank file</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Exporting-report-to-PDF-using-REST-API-returns-blank-file/m-p/3448124#M44681</link>
      <description>&lt;P&gt;Try the same through Power Automate.&amp;nbsp; Note that the PDF export is especially prone to rendering timeouts.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2023 15:26:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Exporting-report-to-PDF-using-REST-API-returns-blank-file/m-p/3448124#M44681</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2023-09-26T15:26:09Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting report to PDF using REST API returns blank file</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Exporting-report-to-PDF-using-REST-API-returns-blank-file/m-p/3449056#M44690</link>
      <description>&lt;P&gt;Seems like that didn't work as well. For some reason, I wasn't able to send the PDF file as attachment to email using Power Automate, but Exporting to a PDF file generated some output like:&lt;/P&gt;&lt;PRE&gt;{"statusCode":200,.......,"body":{"$content-type":"application/pdf","$content":"JVBERi0xLjc............"}&lt;/PRE&gt;&lt;P&gt;I just tried to save the decoded $content to a .PDF file manually, but that didn't work.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2023 06:27:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Exporting-report-to-PDF-using-REST-API-returns-blank-file/m-p/3449056#M44690</guid>
      <dc:creator>pej</dc:creator>
      <dc:date>2023-09-27T06:27:49Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting report to PDF using REST API returns blank file</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Exporting-report-to-PDF-using-REST-API-returns-blank-file/m-p/3449224#M44694</link>
      <description>&lt;P&gt;I managed to make it work with Power Automate in such flow:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="pej_0-1695801963584.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/973789i0D6712171B2F83FB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="pej_0-1695801963584.png" alt="pej_0-1695801963584.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;It successfully export the Paginated Report to PDF and upload it to SharePoint site (for some reason sending an email with attachment didn't work for me).&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, that really doesn't solve my issue of using simple REST API calls. This is a sample code of how I'm executing the 3rd API call to get the file content and save it:&lt;/P&gt;&lt;PRE&gt;axios.get(apiUrl, config)
  .then((response) =&amp;gt; {
    const pdfData = response.data;
    const pdfFilePath = path.join(__dirname, 'ExportedReport.pdf');

    fs.writeFileSync(pdfFilePath, pdfData);
  })&lt;/PRE&gt;&lt;P&gt;, where apiUrl is &lt;A href="https://learn.microsoft.com/en-us/rest/api/power-bi/reports/get-file-of-export-to-file" target="_self"&gt;Get File Of Export To File&lt;/A&gt; endpoint with exportId and reportId parameters.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2023 08:11:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Exporting-report-to-PDF-using-REST-API-returns-blank-file/m-p/3449224#M44694</guid>
      <dc:creator>pej</dc:creator>
      <dc:date>2023-09-27T08:11:59Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting report to PDF using REST API returns blank file</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Exporting-report-to-PDF-using-REST-API-returns-blank-file/m-p/3449899#M44697</link>
      <description>&lt;P&gt;Not clear what you still need to do. The Power Automate action shields all the complexity from you.&amp;nbsp; If you want to do it all manually then you need to work through the complexity.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2023 13:53:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Exporting-report-to-PDF-using-REST-API-returns-blank-file/m-p/3449899#M44697</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2023-09-27T13:53:34Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting report to PDF using REST API returns blank file</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Exporting-report-to-PDF-using-REST-API-returns-blank-file/m-p/3451107#M44705</link>
      <description>&lt;P&gt;Found an error in my implementation. When using Axios for getting binary file data, I need to specify&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;responseType: 'arraybuffer'&lt;/LI-CODE&gt;&lt;P&gt;in the config. So it wasn't really a problem in the APIs itself, just my implementation. Full sample code:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const config = {
  headers: {
    Authorization: `Bearer ${authToken}`,
  },
  responseType: 'arraybuffer'
};

// Send the GET request
axios.get(apiUrl, config)
  .then((response) =&amp;gt; {
    // Handle the response data here
    const pdfFilePath = path.join(__dirname, 'ExportedReport.pdf');
    fs.writeFileSync(pdfFilePath, response.data);
  })&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Sep 2023 06:41:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Exporting-report-to-PDF-using-REST-API-returns-blank-file/m-p/3451107#M44705</guid>
      <dc:creator>pej</dc:creator>
      <dc:date>2023-09-28T06:41:56Z</dc:date>
    </item>
  </channel>
</rss>

