# Problem with API REST Power BI Post Method

**URL:** <https://forums.powershell.org/t/problem-with-api-rest-power-bi-post-method/19338>\
**Category:** PowerShell Help\
**Created:** [May 18, 2022, 6:39am UTC](https://forums.powershell.org/t/problem-with-api-rest-power-bi-post-method/19338 "2022-05-18T06:39:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cha74](https://avatars.discourse-cdn.com/v4/letter/c/da6949/32.png) [@Cha74](https://forums.powershell.org/u/Cha74)\
**Post date:** [May 18, 2022, 6:39am UTC](https://forums.powershell.org/t/problem-with-api-rest-power-bi-post-method/19338/1 "2022-05-18T06:39:42Z")

</div>

Hello,

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

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

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

```

What I did but it doesn’t work :

```auto
$Body = @{
    capacityId = "blblblblbl"
        }

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

```

---

<div class="post-metadata">

**Author:** ![kvprasoon](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/kvprasoon/32/4449_2.png) [@kvprasoon](https://forums.powershell.org/u/kvprasoon)\
**Post date:** [May 18, 2022, 9:04am UTC](https://forums.powershell.org/t/problem-with-api-rest-power-bi-post-method/19338/2 "2022-05-18T09:04:20Z")

</div>

Are you getting any error with the above statement ?

---

<div class="post-metadata">

**Author:** ![Cha74](https://avatars.discourse-cdn.com/v4/letter/c/da6949/32.png) [@Cha74](https://forums.powershell.org/u/Cha74)\
**Post date:** [May 18, 2022, 9:15am UTC](https://forums.powershell.org/t/problem-with-api-rest-power-bi-post-method/19338/3 "2022-05-18T09:15:49Z")

</div>

Hello @kvprasoon,

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

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:17pm UTC](https://forums.powershell.org/t/problem-with-api-rest-power-bi-post-method/19338/4 "2024-05-16T20:17:58Z")

</div>


