manageiq-api icon indicating copy to clipboard operation
manageiq-api copied to clipboard

Can't create a user for multiple groups

Open GilbertCherrie opened this issue 1 year ago • 5 comments

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: Screenshot 2023-08-30 at 3 46 45 PM

This error was hit with the payload: Screenshot 2023-08-30 at 4 57 09 PM

GilbertCherrie avatar Aug 30 '23 21:08 GilbertCherrie

@miq-bot add-label bug

GilbertCherrie avatar Aug 30 '23 21:08 GilbertCherrie

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.

Fryguy avatar Sep 27 '23 17:09 Fryguy

@kbrock Can you add some comments here on what you've found.

Fryguy avatar Sep 27 '23 17:09 Fryguy

I see specs for creating it: https://github.com/ManageIQ/manageiq-api/blob/master/spec/requests/users_spec.rb#L234-L251

kbrock avatar Sep 27 '23 17:09 kbrock

@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. Screenshot 2023-09-28 at 11 22 31 AM

However this is what the API GET call returns for the same user: Screenshot 2023-09-28 at 11 22 17 AM

GilbertCherrie avatar Sep 28 '23 15:09 GilbertCherrie

@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.

kbrock avatar May 09 '24 15:05 kbrock

Closing this issue as fixed since @kbrock's solution of passing :attributes => "miq_groups" fixed the issue.

GilbertCherrie avatar May 10 '24 18:05 GilbertCherrie