Project

General

Profile

Actions

Defect #17904

closed

group membership cannot be added to a project via REST API

Added by Alex Last about 10 years ago. Updated about 10 years ago.

Status:
Closed
Priority:
Normal
Category:
REST API
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Wont fix
Affected version:

Description

environment: Redmine 2.5.2

adding a user with some roles works fine:

Started POST "/redmine/projects/524/memberships.json" for 76.126.10.142 at 2014-09-17 21:04:51 -0700
Processing by MembersController#create as JSON
Parameters: {"membership"=>{"user_id"=>276, "role_ids"=>[3, 4, 5]}, "project_id"=>"524"}
Current user: user (id=1)
Rendered members/show.api.rsb (0.5ms)
Completed 201 Created in 33.9ms (Views: 1.1ms | ActiveRecord: 15.4ms)

but Redmine throws an error when I send a membership object with group_id instead of user_id: {"membership"=>{"group_id"=>275, "role_ids"=>[3]}, "project_id"=>"523"}

log:

Started POST "/redmine/projects/523/memberships.json" for 76.126.10.142 at 2014-09-17 21:02:48 -0700
Processing by MembersController#create as JSON
Parameters: {"membership"=>{"group_id"=>275, "role_ids"=>[3]}, "project_id"=>"523"}
Current user: user (id=1)
Rendered common/error_messages.api.rsb (0.3ms)
Completed 422 Unprocessable Entity in 23.1ms (Views: 1.2ms | ActiveRecord: 4.7ms)

I looked at members_controller.rb file:

def create
members = []
if params[:membership]
if params[:membership][:user_ids]
attrs = params[:membership].dup
user_ids = attrs.delete(:user_ids)
user_ids.each do |user_id|
members << Member.new(:role_ids => params[:membership][:role_ids], :user_id => user_id)
end
else
members << Member.new(:role_ids => params[:membership][:role_ids], :user_id => params[:membership] [:user_id])
end
@project.members << members
end

- there is nothing there to support adding group memberships.

Actions

Also available in: Atom PDF