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
lovepreet81988
Regular Visitor

Try to use rest API(Export to PDF) with Python

I am attempting to utilize the "export to PDF" with REST API query in Power BI, but despite using Power BI, I'm encountering difficulties in generating the PDF file.Please provide me solution to reterei data from reports

4 REPLIES 4
Anonymous
Not applicable

Hi @lovepreet81988 ,

You can refer the following links to get it:

Using Python:

Reports - Export To File - REST API (Power BI Power BI REST APIs) | Microsoft Learn

POST https://api.powerbi.com/v1.0/myorg/reports/{reportId}/ExportTo

GitHub - AntoineDW/powerbi-rest-api-python: A Python library created to easily use the Power BI REST...

pip install pbirest

import pbirest

pbirest.connect(
    client_id = [client_id (required)],
    username = [username (required)],
    password = [password (required)],
    tenant_id = [tenant_id],
    client_secret = [client_secret]
)

Documentation · AntoineDW/powerbi-rest-api-python Wiki · GitHub

pbirest.export_report(workspace_id, report_id, out_file)

Using Postman:

How to use Power BI Rest API to export the Power B... - Microsoft Fabric Community

vyiruanmsft_0-1690335500883.png

Best Regards

hi @Anonymous 

 

Upon attempting to use the POST method with the endpoint URL "https://api.powerbi.com/v1.0/myorg/reports/{reportId}/ExportTo," I encountered an error response: 

{
  "error": {
    "code": "InvalidRequest",
    "message": "Report requested for export is not on dedicated capacity"
  }
}

can u please explain this why i am getting this error

 

Anonymous
Not applicable

Hi @lovepreet81988 ,

There are some limitations when using export to file API, it includes that the report you're exporting must reside on a Premium or Embedded capacity. So please check that your report is in a shared capacity or dedicated capacity...

Export Power BI report to file 

vyiruanmsft_0-1690363252504.png

Best Regards

@Anonymous 
Could you kindly guide me with a step-by-step guide on how to save a report in Embedded capacity?

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

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

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.