Forum Discussion
Power BI Export to file Error
var Client = GetPowerBiClient();
var export = Await Client.Reports.ExportToFileAsync(reportId, exportRequest);
lbendlin If I leave the code as this, it never finishes processing. As a dev, to test, I'm willing to wait maybe 5 minutes, but I left it going for an hour withno results
According to the documentation:
https://docs.microsoft.com/en-us/power-bi/developer/embedded/export-to
Quote: "The API is asynchronous. When the exportToFile API is called, it triggers an export job. After triggering an export job, use polling to track the job, until it's complete.
During polling, the API returns a number that represents the amount of work completed. The work in each export job is calculated based on the number of pages the report has. All pages have the same weight. If for example you're exporting a report with 10 pages, and the polling returns 70, it means that the API has processed seven out of the 10 pages in the export job.
When the export is complete, the polling API call returns a Power BI URL for getting the file. The URL will be available for 24 hours."
- Anonymous6 years agoNot applicable
The export job never finishes.
It never hits the polling function.
The await on the export never comes back.
It should return in a second, max, because the report I'm exporting says only "Test"
Is there some hidden setting or framework version I need to set my project to?
I'm copying the documentation code and it is not working.
- lbendlin6 years agoSuper User
Doesn't look like the sample code to me. I think you are putting one "await" on top of another one?
- Anonymous6 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?