cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
gah113
Advocate I
Advocate I

ExportToFileInGroupAsync Fails with 400 Error (Bad Request)

I am building a .NET application to export Power BI reports hosted on an Azure capacity. The following code fails with a 400 Error (Bad Request) without any information:

 

var reportId = Guid.Parse(powerBiDashboardConfig.ReportId);
var datasetId = Guid.Parse(powerBiDashboardConfig.DatasetId);
var groupId = Guid.Parse(powerBiDashboardConfig.WorkspaceId);

// Set the export configuration properties:
var exportConfiguration = new PowerBIReportExportConfiguration
                          {
                               Settings = new ExportReportSettings
                                    {
                                        Locale = "en-us",
                                        IncludeHiddenPages = true                                        
                                    }
                                };
var exportReportRequest = new ExportReportRequest 
                          {
                               Format = FileFormat.PDF,
                               PowerBIReportConfiguration = exportConfiguration
                                };

// Send the export request:
var export = (await client.Reports.ExportToFileInGroupWithHttpMessagesAsync(groupId, reportId, exportReportRequest)).Body;

 

I have tried making this call manually and the export to PDF works as expected.

5 REPLIES 5
AmosHersch
Microsoft
Microsoft

Hi @gah113 ,

Is the report you're exporting a Power BI (PBIX) report or a Paginated (RDL) report?

Assuming it's a PBIX report I suggest yoy try to see the response message body (using fiddler for example) to see if it contains information regarding the error reason.

The message body reads: "Export report requires effective identity to be provided for the report's dataset"

I have tried to send the exportRequest with an effectiveIdentity and the same error message is returned.

Note that no effective identity is required when manually sending requests to reports/{reportId}/ExportTo via the REST API.

AFAIK this error indicates that your report's dataset has RLS applied, so you must provide an effective identity for that dataset in the export request.

Are you sure you've sent the request with effective identity correctly? Did you specify the dataset ID and RLS parameters?

You can try to export a report with a dataset that doesn't have RLS applied and see that you don't get this error.

When you call the API manually you're not using a Service Principal probably, and hence you don't require to provide an effective identity.

@AmosHersch thanks for your help! We resolved the issue by specifying a dataset ID in the datasets property of the effective identity we were passing.

Any reason this property is required for Export but not for other calls using effective identity (e.g. GenerateToken)?

I would expect this property to be required also in GenerateToken request, especially when the request is from a Service Principal. It might work without an effective identity (or without the property) for a master user.

Helpful resources

Announcements
Carousel_PBI_Wave1

2023 Release Wave 1 Plans

Power BI release plans for 2023 release wave 1 describes all new features releasing from April 2023 through September 2023.

Power BI Summit Carousel 2

Global Power BI Training

Make sure you register today for the Power BI Summit 2023. Don't miss all of the great sessions and speakers!

Thank you 2022 Review

2022 Monthly Feature Releases

We had a great 2022 with a ton of feature releases to help you drive a data culture.