Problem with API REST Power BI Post Method

Hello,

I am new to PowerShell and I don’t understand how to run this command, can you help me ?

POST https://api.powerbi.com/v1.0/myorg/AssignToCapacity

{
  "capacityId": "0f084df7-c13d-451b-af5f-ed0c466403b2"
}

What I did but it doesn’t work :

$Body = @{
    capacityId = "blblblblbl"
        }

Invoke-PowerBIRestMethod -Url "https://api.powerbi.com/v1.0/myorg/groups/blalblalbal/AssignToCapacity" -Method Post -Body ($Body|ConvertTo-Json)

Are you getting any error with the above statement ?

Hello @kvprasoon,

I did some testing so the code works when I use my account but not when I use a Service principal.