[API REST] I can't assign an user to groups

Added by Emmanuel Ghiringhelli 6 months ago

Hello everybody

I would like assign an user to a group with API REST.

I use POST /groups/:id/users.:format syntax (see https://www.redmine.org/projects/redmine/wiki/Rest_Groups)

But it doesn't work.

In redmine log I can see :

Processing by GroupsController#add_users as XML
Parameters: {"group"=>{"user_id"=>"34"}, "key"=>"81aa228c55ac5cfe4264a566ef67ac27702da8eb", "id"=>"5"}
Current user: admin (id=1)
Rendering common/error_messages.api.rsb
Rendered common/error_messages.api.rsb (0.1ms)
Completed 422 Unprocessable Entity in 4ms (Views: 0.4ms | ActiveRecord: 1.3ms)

And in API's response :
Code Error :422
Message : User is invalid
In request body : id of user

User with this id exists in redmine and group too.

Yjank you very much for your response.

Replies (2)

RE: [API REST] I can't assign an user to groups - Added by Emmanuel Ghiringhelli 6 months ago

I think the problem comes from the data in request_body.

I put <group><user_id>XXX</user_id></group>

In documentation, I can see <user_id>XXX</user_id> only, but i have a bad request error....

(1-2/2)