Power BI Export Report into PDF – REST API Support

ByHariharan Rajendran

Power BI Export Report into PDF – REST API Support

This article explains a most wanted solution in most of the organizations. Yes, it is talking about exporting a Power BI report into pdf, ppt and png. You may think that these options are already available and why I have taken this topic. Yes, we can export a report into pdf or ppt but we manually need to go to report and choose the export option to get the report in either pdf or ppt.

I will tell you how to automate this process, I mean you no need to open the report manually and export it. We also have subscription option which does the same but not in an effective way. I would say still (when am writing this article). Power BI does not have a proper subscription feature. There are lot of limitations. Check Power BI Subscription in Microsoft documentation.

This article refers the Power BI REST API which release by Power BI team recently for exporting the report into pdf, ppt and png. Refer – https://powerbi.microsoft.com/en-us/blog/export-report-to-pdf-pptx-and-png-files-using-power-bi-rest-api/

I would say this is fantastic update from Power BI team which enables us to perform so many options and it will be the alternative for proper subscription feature in Power BI.

Use Cases

  1. Build your own custom subscriptions
  2. Enable users to download their report into pdf whenever they need without opening the report.
What are those REST APIs?

We have 2 to 3 REST APIs to support following actions.

Export the file – https://api.powerbi.com/v1.0/myorg/groups/{groupId}/reports/{reportId}/ExportTo

Check the Status – https://api.powerbi.com/v1.0/myorg/groups/{groupId}/reports/{reportId}/exports/{exportId}

Download the file – https://api.powerbi.com/v1.0/myorg/groups/{groupId}/reports/{reportId}/exports/{exportId}/file

The above all REST APIs are support in both My Workspace and App workspace but the workspace should reside in Power BI Premium Capacity.

The Following article explains how to use these REST APIs in C# code – https://docs.microsoft.com/en-us/power-bi/developer/embedded/export-to

Let me explain, how to use PowerShell script to perform export the file and download the file.

What you need to test?
  1. Register an Azure APP and get the Client ID – https://dev.powerbi.com/apps
  2. Power BI Premium Capacity to your workspace – You can use your Power BI Premium Capacity or Azure Power BI Embedded Capacity.
  3. Sample report published into your workspace
  4. Get Workspace & Report ID

Open your Power BI report in browser and get the id.

In the above image, id after groups is Workspace ID or GroupID and Report ID is available after Reports.

Export a File

Use the below URL,


Replace the $Group_ID and $Report_ID with whatever you got from your report URL.

Export file REST API is a POST method and it also requires Body when we request the URL. I have using pdf format.

Refer the below PowerShell script.

$uri = “https://api.powerbi.com/v1.0/myorg/groups/$Group_ID/reports/$Report_ID/ExportTo”

$body = “{`”format`”:`”pdf`”}”

$FileExport = Invoke-RestMethod -Uri $uri –Headers $auth_header –Method POST -body $body

 Get File Status

Above step triggers the export file job, we need to know the status of the export. If the export status is completed means the file is ready to download.

This is a GET method.

Get the Export file id from above PowerShell script and use it in below REST API.

Invoke-RestMethod -Uri $uri –Headers $auth_header –Method GET

Use the below PowerShell script.

$id = $FileExport.id

$uri = “https://api.powerbi.com/v1.0/myorg/groups/$Group_ID/reports/$Report_ID/Exports/$id”

$FileStatus = Invoke-RestMethod -Uri $uri –Headers $auth_header –Method GET

Get or Download a file

Again it is using GET method. Following URL is the REST API URL.


Here $id is Export file id which we get from Export file section.

Use the below PowerShell script.

$uri = “https://api.powerbi.com/v1.0/myorg/groups/$Group_ID/reports/$Report_ID/Exports/$id/file”

$File = Invoke-RestMethod -Uri $uri –Headers $auth_header –Method GET -OutFile $Folder+”_new.pdf”

I am using -OutFile option to get the file stored in local folder with filename with extension as .pdf.

Get the full script from my GitHub Repository.

Next article, I will cover the Use cases with this REST API.

About the Author

Hariharan Rajendran author

Hariharan Rajendran is a MVP in Data Platform and Microsoft Certified Trainer with 10+ years of experience in Database, BI and Azure platforms. Hariharan is also an active community leader, speaker & organizer and leads the Microsoft PUG (Power BI User Group – Chennai), SQLPASS Power BI Local Group – Chennai and an active speaker in SQL Server Chennai User Group and also a leader in Data Awareness Program worldwide events. Hariharan also frequently blogs (www.dataap.org/blog), provides virtual training (on ad-hoc basis) on Microsoft Azure, Database Administration, Power BI and database development to worldwide clients/audience.

4 Comments so far

AdilPosted on  12:14 am - Jun 3, 2020

Hi Hariharan

This is nice article. I am trying to execute the script. it is giving an error when downloading a file which seems thant status is still running and not completed and we try to download the file.

I have tried the same using DotNet API, but unable to download file.

can you help in resolving this issues?

FileStatus: @{@odata.context=http://wabi-australia-southeast-redirect.analysis.windows.net/v1.0/myorg/groups/1e10d85a-123d-453d-93d6-2de2d2eadf7a/$metadata#exports/$entity; id=Mi9CbG9iSWRWMi1mZGJlMTY4My04YTQ5LTQyNWUtYjQ4Ny1mYjdmNmU5OWI1Mzd1ZC5GSTJHYTB5QTU2Mm
YzLXpCV043d1l5dnJDd2hlS0VUZ0k4WVBjUi4=; createdDateTime=2020-06-03T00:09:56.6553596Z; lastActionDateTime=2020-06-03T00:09:56.7495993Z; reportId=c1fc59fe-f0ce-414a-bdee-cedb0c90f28d; reportName=2018SU07 Blog Demo – July; status=Running; percentComplete=0; exp

Hariharan RajendranPosted on  10:58 am - Jul 10, 2020

Are you running the correct script?

peter maiPosted on  9:05 pm - Oct 9, 2020

If I need to pass in a parameter, where would it go?
In the app, I’d just append ?rp:some_id=some_value to the end of the URL

Hariharan RajendranPosted on  4:31 pm - Oct 13, 2020

Hi, We have parameter support in REST API for paginated reports.

Leave a Reply

71 − 68 =