I have been trying to clone both a power bi report and its dataset using PBI Rest APIs. Looks like there is no direct way to copy a dataset. There is a post about this issue, where it is recommended to download PBI report and dataset as a stream and import them back to PBI workspace:
PowerBI API Clone Report and Dataset changing the datasource
I have tried to export PBI using PBI APIs and powershell as it is explained here:
https://learn.microsoft.com/en-us/rest/api/power-bi/reports/export-report
https://github.com/microsoft/PowerBI-Developer-Samples/blob/master/PowerShell%20Scripts/Export-PowerBIReport.ps1 However, I am getting the following error:
Export-PowerBIReport : Operation returned an invalid status code 'BadRequest'
At line:11 char:3
+ Export-PowerBIReport -Id $reportId -WorkspaceId $workspace.Id -OutF ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (Microsoft.Power...rtPowerBIReport:ExportPowerBIReport) [Export-PowerBIRepor
t], HttpOperationException
+ FullyQualifiedErrorId : Operation returned an invalid status code 'BadRequest',Microsoft.PowerBI.Commands.Report
s.ExportPowerBIReport
VERBOSE: Request Uri:
https://api.powerbi.com/v1.0/myorg/groups/XXXXXXX/reports/XXXXXXXX/Export
VERBOSE: Status Code: BadRequest (400)
Can you please help with how to export PBI as a stream with detailed steps?
Thank you so much in advance!
I have tried PBI Rest APIs and powershell, but it has not worked for me yet. I would like to copy a PBI report & its dataset.
I'm not sure about what do you want to do. Do you want to export (download) or cloning (copying report in the PowerBI Service) a report ?
If you want to export (download) a report then you can use this API this will export a report and its dataset (.pbix)
If you want to clone (copy a report from a workspace to another) you can use this API.
If If the Parameter 'targetModelId' (dataset) is not provided, the new report will be associated with the same dataset as the source report. And If If the Parameter 'targetWorkspaceId' (dataset) isn't provided, the new report will be cloned within the same workspace as the source report.
You have BadRequest (400) that mean something is wrong on your Uri, check the IDs