Forum Discussion

sanjeevgaut's avatar
sanjeevgaut
Frequent Visitor
5 years ago

Reports - Export To File , with filter options and pageName not working

Hi 

 

I am trying to export report , with applied filter and for some page. i am getting error "Operation returned an invalid status code 'BadRequest'"

Below is my code.

 

var urlFilter = "Distry=CMC";
ExportReportPage pages1w3 = new ExportReportPage("ReportSection0");
IList<ExportReportPage> pageNames = new List<ExportReportPage> { pages1w3 };

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,
// ReportLevelFilters collection needs to be instantiated explicitly
ReportLevelFilters = !string.IsNullOrEmpty(urlFilter) ? new List<ExportFilter>() { new ExportFilter(urlFilter) } : null,

};

var exportRequest = new ExportReportRequest
{
Format = FileFormat.ACCESSIBLEPDF,
PowerBIReportConfiguration = powerBIReportExportConfiguration,
};

var export = client.Reports.ExportToFile(ReportId, exportRequest);

 

Any help appreated..

3 Replies