Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
pej
Regular Visitor

Exporting report to PDF using REST API returns blank file

Hello guys,

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 Premium Per User workspace, where I have my Paginated Report:

pej_0-1695647023718.png

I'm calling these API endpoints:

1. Export To File (to initialize exporting)

2. Get Export To File Status (for polling status)

3. Get File Of Export To File (retrieve the file)

 

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.

 

I'm trying to also read through consideration and limitations for exporting paginated reports, but that wasn't that much helpful and it doesn't explain why the CSV would work and PDF not.

 

Any help will be appreciated. Thanks!

1 ACCEPTED SOLUTION

Found an error in my implementation. When using Axios for getting binary file data, I need to specify 

responseType: 'arraybuffer'

in the config. So it wasn't really a problem in the APIs itself, just my implementation. Full sample code:

const config = {
  headers: {
    Authorization: `Bearer ${authToken}`,
  },
  responseType: 'arraybuffer'
};

// Send the GET request
axios.get(apiUrl, config)
  .then((response) => {
    // Handle the response data here
    const pdfFilePath = path.join(__dirname, 'ExportedReport.pdf');
    fs.writeFileSync(pdfFilePath, response.data);
  })

 

View solution in original post

5 REPLIES 5
lbendlin
Super User
Super User

Try the same through Power Automate.  Note that the PDF export is especially prone to rendering timeouts.

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:

{"statusCode":200,.......,"body":{"$content-type":"application/pdf","$content":"JVBERi0xLjc............"}

I just tried to save the decoded $content to a .PDF file manually, but that didn't work.  

pej
Regular Visitor

I managed to make it work with Power Automate in such flow:

pej_0-1695801963584.png

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). 

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:

axios.get(apiUrl, config)
  .then((response) => {
    const pdfData = response.data;
    const pdfFilePath = path.join(__dirname, 'ExportedReport.pdf');

    fs.writeFileSync(pdfFilePath, pdfData);
  })

, where apiUrl is Get File Of Export To File endpoint with exportId and reportId parameters. 

Not clear what you still need to do. The Power Automate action shields all the complexity from you.  If you want to do it all manually then you need to work through the complexity.

Found an error in my implementation. When using Axios for getting binary file data, I need to specify 

responseType: 'arraybuffer'

in the config. So it wasn't really a problem in the APIs itself, just my implementation. Full sample code:

const config = {
  headers: {
    Authorization: `Bearer ${authToken}`,
  },
  responseType: 'arraybuffer'
};

// Send the GET request
axios.get(apiUrl, config)
  .then((response) => {
    // Handle the response data here
    const pdfFilePath = path.join(__dirname, 'ExportedReport.pdf');
    fs.writeFileSync(pdfFilePath, response.data);
  })

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.