Api script to add user to group

Hi,

We're writing some reports the GET function is working fine, but when we make POST to add new user to group we get error 400, can someone point me at right direction or tell me what i'm doing wrong, with same script just modified the body part i can create the user, but then i cant put in a group.

after authenticate this is the relevant script lines

$headersX = @{
'New-Object' = 'System.Collections.Generic.Dictionary[[String],[String]]'
'X-Tenant-ID' = 'tenantid'
'Authorization' = 'Bearer $res'
'Accept' = 'application/json'
'Content-Type' = 'application/json'
}

############################

$body.Add("ids" , "userid")

$data = $body | ConvertTo-Json

##########################

Invoke-RestMethod -Uri 'url api/common/v1/directory/user-groups/griupid/users' -Method POST -Body $data -Headers $headersX

return error 400 bad request, but with same script i can create new user