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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors