Forum Discussion
Power BI Export to file Error
/////// 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?
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
In the main application, the C# simply won't move past that line - do not know why. Nothing I do will work to move it past there.
- 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...
- Anonymous5 years agoNot applicable
Have you found a resolution for this. Stuk with the same issue!
- Anonymous4 years agoNot applicable
I found when I tried to export the file as a .PNG or a .CSV then the api call never worked and just hung permanently. But when I changed the export format to .PDF then it worked fine and the code was able to move on to the 'polling for export to finish' logic.
- Anonymous4 years agoNot applicable
hi, did you use the sample code that is in the microsoft doc?
if not, can i see you your code .
thanks