Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Unable to add groups to a workspace using Rest API

l need to use powershell to add a group to an existing workspace

 

Invoke-RestMethod -Method POST -Uri "https://api.powerbi.com/v1.0/myorg/groups/<groupId>/users" -Header @{Authorization = 'Bearer $token'; 'Content-type' = 'application/json'; 'User-Agent' = 'Jenkins'} -Body '{"principalType" = "Group", "groupUserAccessRight"= "Admin", "identifier"= "ID", "displayName"="MyGroupName"}'

 

I keep getting (400) Bad Request error. I am able to add individual users with this body:

{"groupUserAccessRight"= "Admin", "emailAddress"= "[email protected]"}

 

 

What am I doing wrong to add groups?

 

EDIT: The problem seem to be the identifier number I am using. I am not sure how to retrieve the proper one though

2 Replies