I'm trying to upload PowerBI .pbix report stored on my local PC to PowerBI Service using Rest API. I haven't had problems exporting reports to my computer before, only agonizing over importing them to the server.
Here is the documentation: https://learn.microsoft.com/en-us/rest/api/power-bi/imports/post-import-in-group
And mycode:
Connect-PowerBIServiceAccount
$file = "C:\Sales.pbix"
$Payload =@"
{ "ImportInfo" : { "filePath" : "$file" , "connectionType" : "import" }}
"@
Invoke-PowerBIRestMethod -Url "https://api.powerbi.com/v1.0/myorg/groups/<here I put workspace ID>/imports?datasetDisplayName=Test" -Method Post -Body $Payload -ContentType 'application/json'
And error:
Invoke-PowerBIRestMethod : One or more errors occurred.
At line:21 char:1
+ Invoke-PowerBIRestMethod -Url "https://api.powerbi.com/v1.0/myorg/gro ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (Microsoft.Power...werBIRestMethod:InvokePowerBIRestMethod) [Invoke-PowerBIRestMethod], AggregateException
+ FullyQualifiedErrorId : One or more errors occurred.,Microsoft.PowerBI.Commands.Profile.InvokePowerBIRestMethod