When posting to the Power BI api uri: https://api.powerbi.com/v1.0/myorg/groups in PowerShell version 5.1.17134.228, I got the error:

The remote server returned an error: (500) Internal Server Error.


I invoked the Power BI rest api with the PowerShell script you can find below.

The error was fixed, when I added -ContentType ‘application/json’ parameter to the InvokeRestMethod



PowerShell script


$clientId = “my-client-id”

$PowerBIUserName = “MyUserName”

$PowerBIUserPassword = “MyUserPassword”

$creds = New-Object “Microsoft.IdentityModel.Clients.ActiveDirectory.UserCredential” -ArgumentList $PowerBIUserName,$PowerBIUserPassword

$resourceAppIdURI = “https://analysis.windows.net/powerbi/api”

$authority = “https://login.microsoftonline.com/common/oauth2/authorize”;

$authContext = New-Object “Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext” -ArgumentList $authority


# Acquire token

$authResult = $authContext.AcquireToken($resourceAppIdURI, $clientId, $creds)


# Create a new group

$auth_header = @{



$uri = “https://api.powerbi.com/v1.0/myorg/groups”

$body = “{`”name`”:`”myNewGroup`”}”

$response = Invoke-RestMethod -Uri $uri -Headers $auth_header -Method POST -Body $body -ContentType ‘application/json’

$target_group_id = $response.id





Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.