Forum Discussion
Anonymous
6 years agoNot applicable
Power BI Export to file Error
We are using the latest version of the API (V3) I have copied the code examples from here - https://docs.microsoft.com/en-us/power-bi/developer/embedded/export-to in my 'PostExportRequest' functi...
lbendlin
6 years agoSuper User
Doesn't look like the sample code to me. I think you are putting one "await" on top of another one?
Anonymous
6 years agoNot applicable
/////// Export sample ///////
public async Task<string> PostExportRequest(
Guid reportId,
Guid groupId,
FileFormat format)
{
var client = GetPowerBiClient(); // new Power BI client instance
var pages = client.Reports.GetPages(groupId, reportId);
var powerBIReportExportConfiguration = new PowerBIReportExportConfiguration
{
Settings = new ExportReportSettings
{
Locale = "en-us",
},
};
var exportRequest = new ExportReportRequest
{
Format = format,
PowerBIReportConfiguration = powerBIReportExportConfiguration,
};
Export export = null;
try
{
export = await client.Reports.ExportToFileInGroupAsync(groupId, reportId, exportRequest); // this never returns
}
catch (Exception ex)
{
}
// Save the export ID, you'll need it for polling and getting the exported file
return export.Id;
}
Here's my full function.
Do I have a double await?
- lbendlin6 years agoSuper User
You define the pages but then do not specify them in the request.
(You also use Export export instead of var export but I guess that doesn't matter)
- Anonymous6 years agoNot applicable
I deleted the line with 'pages' since yes, I'm not using them.
If I don't specify pages, then it'll export the whole report, right?
- lbendlin6 years agoSuper User
That would make too much sense. So better test with specifying the pages , just in case...