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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Using Power BI REST API to export a report

I am working on a python script to export reports from a workspace using Power BI Rest API:

 

headers={"Authorization": f"Bearer{token}"}

url = https://api.powerbi.com/v1.0/myorg/groups/{groupId}/reports/{reportId}/Export

response = requests.get(url, headers=headers)

with open(f"{folder_path}/{file_name}.pbix","wb") as report:

     report.write(io.BytesIO(response.content).getbuffer())

 

It's working for files less than 100mb but  I'm getting a 500 internal server error 500 for files greater than 100mb

I've also tried with the workaround mentioned here: https://learn.microsoft.com/en-us/rest/api/power-bi/reports/export-report-in-group

by using GET https://api.powerbi.com/v1.0/myorg/groups/{groupId}/reports/{reportId}/Export?preferClientRouting=tr... and it is giving me "403 client error: forbidden for url: https://api.powerbi.com/v1.0/myorg/groups/{groupId}/reports/{reportId}/Export" 

 

The logic I have used to get the token

 

url =  https://login.microsoftonline.com/<tenant>/oauth2/v2.0/token 

headers = {"Content-Type": "application/x-www-form-urlencoded"}

response = requests.post(url, data=payload,headers=header)

token = response.json()["access_token"]

In payload I have given the client ID, secret and the scope.

 

How can I resolve this issue? 

Thanks in advance!

 

 

 

Status: Investigating
Comments
Anonymous
Not applicable

Hi @fariayakhan 

I tried to restore your scene, but failed.

Based on the above information, if you are a Power BI Pro licensee, you can create a support ticket for free and a dedicated Microsoft engineer will come to solve the problem for you.

The link of Power BI Support: https://powerbi.microsoft.com/en-us/support/

For how to create a support ticket, please refer to https://community.powerbi.com/t5/Community-Blog/How-to-create-a-support-ticket-in-Power-BI/ba-p/6830...

 

Best Regards,
Community Support Team _ Ailsa Tao

fariayakhan
Regular Visitor

Hi @Anonymous,


I have raised a ticket for this issue over two months ago and we have been able to resolve it yet.

The Power BI team has collected network traces to diagnose the issue and they have provided a few solutions such a increasing the Connection timeout header but the issue persists.

 

Additionally, it takes about 3-4 for reports that are 40-70 MB in size.

 

Kindly help me with this

 

Thanks & Regards,

Faria