Forum Discussion
Want to add Export Power BI Report Feature in my application where in embed the report
- 6 years ago
You will have to implement the asynchronous process described in the documentation. Your app needs to call the API with the export request, receive the job ID, then your app needs to poll the API with the job ID for the render status, and once rendering is complete, your app can then download the resulting blob and offer it to the app users for their download etc.
Test it out in the sandbox.
https://docs.microsoft.com/en-us/rest/api/power-bi/reports/exporttofileingroup
After testing it out in the sandbox, I fix few thing in my code and now it is executing completely.
Here is the code , which i did.
public async Task<ExportedFile> ExportPowerBIReport(Guid ReportID, Guid GroupID, FileFormat format, int pollingtimeOutInMinutes, CancellationToken token, IList<string> pageNames = null)
{
try
{
var exportId = await PostExportRequest(ReportID, GroupID, format, pageNames);
var export = await PollExportRequest(ReportID, GroupID, exportId);
if (export == null || export.Status != ExportState.Succeeded)
{
// Error, failure in exporting the report
return null;
}
return await GetExportedFile(ReportID, GroupID, export);
}
catch(Exception ex)
{
// Error handling
throw ex;
}
}
but the problem i am facing right now is after executing the last line, i.e.
return await GetExportedFile(ReportID, GroupID, export);
it takes me to the browser with a error pop-up. just "error" written on it.. and the report didn't downloaded.
My report is consist of 3 pages, so do i am referring the right document ? or i should go with this one ?https://docs.microsoft.com/en-us/power-bi/developer/embedded/export-paginated-report