Forum Discussion
mhall23
Dec 14, 2021Copper Contributor
Add group member 400 Bad Request
I keep getting a 400 Bad Request when adding members to groups via graph api in powershell. I think it's an issue with oddata part and passing the user id.
I tried a few different ways with the $body part but keep getting 400 bad requests errors.
What's the correct way to pass the userid when adding a new member to a group?
These are the commands I'm using in powershell:
$userid =''
$URL = 'https://graph.microsoft.com/v1.0/groups/617a38f4-a084-4027-9c1a-6e5c24f292de/members/$ref'
$Body = @{
>> '@odata.id' = "https://graph.microsoft.com/v1.0/directoryObjects/$($userid)"
>> }
Invoke-RestMethod -Headers $headers -Uri $URL -Method POST -Body $body -ContentType 'application/json'
No RepliesBe the first to reply