Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.