'PowerBI API + Export Report to PDF Error 'NotFound'

I have this simple C# console app project which I'm trying to export a PBI report to PDF.

I have the Azure and PBI accounts all set up, premium license, everything.

I can also connect to the PBI account through this code, search and find the correct workspace and report using their names.

The problem is when I call the pbiClient.Reports.ExportToFileInGroup method, which always return me the error below:

Unhandled exception. Microsoft.Rest.HttpOperationException: Operation returned an invalid status code 'NotFound'
   at Microsoft.PowerBI.Api.ReportsOperations.ExportToFileInGroupWithHttpMessagesAsync(Guid groupId, Guid reportId, ExportReportRequest requestParameters, Dictionary`2 customHeaders, CancellationToken cancellationToken)
   at Microsoft.PowerBI.Api.ReportsOperationsExtensions.ExportToFileAsync(IReportsOperations operations, Guid groupId, Guid reportId, ExportReportRequest requestParameters, CancellationToken cancellationToken)
   at Microsoft.PowerBI.Api.ReportsOperationsExtensions.ExportToFile(IReportsOperations operations, Guid groupId, Guid reportId, ExportReportRequest requestParameters)   
   at ExportReportToFile.Models.PowerBiExportManager.ExportPowerBIReport(Guid WorkspaceId, Guid ReportId, String ExportName, FileFormat ExportFileFormat, String ExportFilter) in \dev\tmp\pbiExportPoc\ExportReportToFile\Models\PowerBiExportManager.cs:line 140
   at ExportReportToFile.Program.Main() in \dev\tmp\pbiExportPoc\ExportReportToFile\Program.cs:line 24

The repo is here => https://github.com/andremorata/PBIExportSample

I can assure you that the workspace and report IDs are correct.

Any thoughts?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source