Using the API to add a user to a group
Hi all
I am trying to use the API to create users and assign them to a specific usergroup.
I can use the POST to /api/v1/localusers/ to create a user with a relevant JSON as body. This seems to work just fine. I am a bit annoyed that I can't just add the user_groups to that request, but so be it.
Then I can find all usergroups usign this GET: /api/v1/usergroups/ - This will return all the usergroups along with their "resource_uri". This works fine.
Now, how do I add a user to the group? I don't want to use the PATCH to the /api/v1/usergroups because that would require me to include ALL the users in the PATCH-call. I just need to add a user. So I thought the best way was to use the POST to the /api/v1/localgroup-memberships/ - but it fails for me.
If I provide this JSON:
{
"group": "/api/v1/usergroups/2/",
"user": "/api/v1/localusers/25/"
}
I get an error back: "Cannot add facgroup-user relationship "FacGroup_users object (None)" (Response: HTTP 400), Error:"
So... How do I add a newly created localuser to the existing usergroup?
Thanks! :)
Jan