Hi all
I was creating a docker image for the 1.19 RC, with some initial configuration. For adding some user groups and testing the link to ldap I was using the REST api, more specifically a POST to api/v2/usergroups/:usergroup/external_usergroups as explained in API documentation. I was using this command, to create the external usergroup.
curl -s -H Accept:application/json -H Content-Type:application/json -k -u admin:changeme -X POST -d {“name”:“administrator”,“auth_source_id”:34} https://172.19.0.1/api/v2/usergroups/1/external_usergroups
I found an error using it, the server was complaining about: “Usergroup can’t be blank”, crashing with “NoMethodError: undefined method ‘users’ for nil:NilClass”. Even if I have no experience with ruby after some research, finally I fixed it modifiing the file app/controllers/api/v2/external_usergroups_controller.rb at the line 36. I include the resulting patch:
diff --git a/app/controllers/api/v2/external_usergroups_controller.rb b/app/controllers/api/v2/external_usergroups_controller.rb
index 71102c375..da827657d 100644
--- a/app/controllers/api/v2/external_usergroups_controller.rb
+++ b/app/controllers/api/v2/external_usergroups_controller.rb
@@ -36,7 +36,7 @@ module Api
param_group :external_usergroup, :as => :create
def create
- @external_usergroup = @nested_obj.external_usergroups.new(external_usergroup_params)
+ @external_usergroup = @nested_obj.external_usergroups.new(external_usergroup_params.merge(:usergroup_id => params[:usergroup_id]))
process_response @external_usergroup.save
end
Kind regards
Gorka