manageiq-api
manageiq-api copied to clipboard
Can't create a user for multiple groups
As described in the docs: https://www.manageiq.org/docs/reference/latest/api/reference/users.html#creating-users I tried to crate a user using the API. The current Add user page allows for users to be created as part of multiple groups but there does not seem to be any way to do this with the API according to the documentation. When trying to pass in multiple groups using an array I hit the error:
This error was hit with the payload:
@miq-bot add-label bug
When this gets worked on we have to make sure we distinguish current group from "all groups. I wonder if this just needs subcollection support.
@kbrock Can you add some comments here on what you've found.
I see specs for creating it: https://github.com/ManageIQ/manageiq-api/blob/master/spec/requests/users_spec.rb#L234-L251
@kbrock It looks like the POST call to add/edit is working in terms of adding a user to multiple groups. However I think the GET call to get a user data is broken because when trying to call GET on a specific user id it returns only the current group not all the groups the user is in.
This is the summary page showing all 5 groups that I selected on the add/edit page showing that it is POSTing the data correctly.
However this is what the API GET call returns for the same user:
@GilbertCherrie you can get the groups by passing the parameter: :attributes => "miq_groups"
.
I ensured it worked with both an individual user and a collection of users.
Closing this issue as fixed since @kbrock's solution of passing :attributes => "miq_groups"
fixed the issue.