Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

View all the Fabric Data Days sessions on demand. View schedule

Reply
rafal_walisko
Helper I
Helper I

Post Import into Group

Here is my code in PS

 

Connect-PowerBIServiceAccount
$body = '{
    "filePath": "C:\Sales.pbix"
  }'
$uri = "https://api.powerbi.com/v1.0/myorg/groups/4b624492-ab58-4606-ba89-d6fd68e0904b/imports?datasetDisplayName=Report"
Invoke-PowerBIRestMethod -Url $uri  -Method Post -Body $Body
Disconnect-PowerBIServiceAccount

 

And I've got the following error

 

Invoke-PowerBIRestMethod : One or more errors occurred.
At line:8 char:1
+ Invoke-PowerBIRestMethod -Url $uri  -Method Post -Body $Body
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (Microsoft.Power...werBIRestMethod:InvokePowerBIRestMethod) [Invoke-PowerBIRestMethod], AggregateException
    + FullyQualifiedErrorId : One or more errors occurred.,Microsoft.PowerBI.Commands.Profile.InvokePowerBIRestMethod

 

What Should I change in that code to be able to export .pbix file from my pc to Powerbi Sevice

2 REPLIES 2
jaweher899
Impactful Individual
Impactful Individual

The error message you are receiving is indicating that there were one or more errors that occurred during the execution of your PowerShell script. Without more information on what caused the error, it is difficult to determine exactly what changes you need to make to your script.

However, based on the code you provided, it appears that you are trying to import a .pbix file into a specific group in your Power BI tenant. To do this, you will need to make sure that you have the correct permissions to import a file into the specified group.

Here are a few things you can try to troubleshoot the error:

  1. Check your credentials: Make sure that you are using the correct credentials to connect to the Power BI service. You can try running the Connect-PowerBIServiceAccount cmdlet separately to verify that you are able to connect to the service.

  2. Check the group ID: Make sure that the group ID you are using in the URL is correct. You can try using the Get-PowerBIGroup cmdlet to list all the groups you have access to, and double-check that the ID you are using matches the correct group.

  3. Check the file path: Make sure that the file path you are specifying in the JSON body is correct. You may need to escape any backslashes in the file path with an additional backslash, like this: "C:\\Sales.pbix"

  4. Check the dataset display name: Make sure that the dataset display name you are specifying in the URL is unique within the specified group. If there is already a dataset with that display name in the group, the import will fail.

  5. Check the file size: Make sure that the .pbix file you are trying to import is not too large. There is a limit on the file size that you can import into Power BI, which is currently set to 2 GB.

If you continue to have issues, you may need to provide more information on the specific error message that you are receiving. You can try wrapping your code in a Try...Catch block to capture any errors and display them in the console:

Try {
Connect-PowerBIServiceAccount
$body = @{
filePath = "C:\Sales.pbix"
}
$uri = "https://api.powerbi.com/v1.0/myorg/groups/4b624492-ab58-4606-ba89-d6fd68e0904b/imports?datasetDispla..."
Invoke-PowerBIRestMethod -Url $uri -Method Post -Body $body
} Catch {
Write-Error $_.Exception.Message
} Finally {
Disconnect-PowerBIServiceAccount
}

Please do not post chatGPT answers.

 

I was also trying to do something like this:

 

Connect-PowerBIServiceAccount
$Payload =@"
{ "ImportInfo" : { "filePath" : "$file" , "connectionType" : "import" }}
"@

$Payload = '{ "ImportInfo" : { "filePath" : Sales.pbix , "connectionType" : "import" }}'

Invoke-PowerBIRestMethod -Url "https://api.powerbi.com/v1.0/myorg/groups/4b624492-ab58-4606-ba89-d6fd68e0904b/imports?datasetDisplayName=Test" -Method Post -Body $Payload -ContentType 'application/json'

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.