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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
pbi_sujay
New Member

How to download/export PowerBI report .PBIX file from PBI service using REST API in Python?

I am able to download .pbix file from PBI service using powershell Invoke-PowerBIRestMethod rest api please find below runnable code

 

$ApiUrl = "https://api.powerbi.com/v1.0/$groupsPath/reports/$reportId/Export"

 

#Export power BI file to current directory
$export_id = Invoke-PowerBIRestMethod -Url $ApiUrl -Headers $auth_header -Method GET -ContentType "application/zip" -OutFile $filePath -TimeoutSec 0 -Verbose

 

But unable to process this in python. Can you help here for missing paramter or what I am missing.
While converting into python Im using below code:

 

Target URL: The target API is GET - https://api.powerbi.com/v1.0/myorg/groups/$reportId/reports/$groupId/Export

 

Header: { Authorization: bearer 'access_tocken', Content-Type: application/zip}

 

 

1 ACCEPTED SOLUTION
V-lianl-msft
Community Support
Community Support

Hi @pbi_sujay ,

 

You can refer to the sample:

https://github.com/cmberryau/pypowerbi/blob/master/pypowerbi/reports.py 

For more details,you can refer to this blog:

https://www.datalineo.com/post/power-bi-rest-api-with-python-and-microsoft-authentication-library-ms... 


Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
V-lianl-msft
Community Support
Community Support

Hi @pbi_sujay ,

 

You can refer to the sample:

https://github.com/cmberryau/pypowerbi/blob/master/pypowerbi/reports.py 

For more details,you can refer to this blog:

https://www.datalineo.com/post/power-bi-rest-api-with-python-and-microsoft-authentication-library-ms... 


Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

lbendlin
Super User
Super User

The spelling is different.  Use Bearer  (capital B)  and no single quotes around the token.

Hi , Yes we already tried that but it did not work.

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.