Export Power BI reports to PDF, PPTX or PNG files using REST API is in preview now
Note that both the report and the dataset of the report you are exporting must reside on a premium or embedded capacity. Other preview limitations are detailed in the Export report to file article.
Please also be aware that as all new Power BI APIs, the Export-To-File API is included only in the Power BI APIs .NET SDK v3.
You can find here in official doc all the information required to use Power BI REST APIs to Export To File
Scenario 2: use parameter ExportReportPage
Scenario 1: Using reportLevelFilters in PowerBIReportExportConfiguration, you can export a report in a filtered condition. To export a filtered report, insert the URL query string parameters you want to use as your filter, to ExportFilter. When you enter the string, you must remove the ?filter= part of the URL query parameter.
here is the code example for Export request: End-to-end example
https://docs.microsoft.com/en-us/power-bi/developer/embedded/export-to#limitations
Please refer to embedded links
Example, an export request is sent for a specific page.
private async Task<string> PostExportRequest(
Guid reportId,
Guid groupId,
FileFormat format,
IList<string> pageNames = null, /* Get the page names from the GetPages REST API */
string urlFilter = null)
{
var powerBIReportExportConfiguration = new PowerBIReportExportConfiguration
{
Settings = new ExportReportSettings
{
Locale = "en-us",
},
// Note that page names differ from the page display names
// To get the page names use the GetPages REST API
Pages = pageNames?.Select(pn => new ExportReportPage(Name = pn)).ToList(),
// ReportLevelFilters collection needs to be instantiated explicitly
ReportLevelFilters = !string.IsNullOrEmpty(urlFilter) ? new List<ExportFilter>() { new ExportFilter(urlFilter) } : null,
};
var exportRequest = new ExportReportRequest
{
Format = format,
PowerBIReportConfiguration = powerBIReportExportConfiguration,
};
// The 'Client' object is an instance of the Power BI .NET SDK
var export = await Client.Reports.ExportToFileInGroupAsync(groupId, reportId, exportRequest);
// Save the export ID, you'll need it for polling and getting the exported file
return export.Id;
}