Greetings, Foreman people.
I'm trying to update a user via the REST API and am getting a 500 error
doing so. Relevant code is as follows, using the rest-client rubygem:
require 'json'
require 'rest_client'
RestClient::Resource.new(
url,
:headers => {
:content_type => :json,
:accept => :json,
},
:ssl_ca_file => '/etc/pki/cacerts/cacerts.pem',
:ssl_client_cert =>
OpenSSL::X509::Certificate.new(File.read("/etc/pki/public/#{Socket.gethostname}.pub")),
:ssl_client_key =>
OpenSSL::PKey::RSA.new(File.read("/etc/pki/private/#{Socket.gethostname}.pem")),
:ssl_version => :TLSv1_2,
:user => 'admin',
:password => 'draw me like one of your french girls',
:verify_ssl => OpenSSL::SSL::VERIFY_PEER,
).put( {'user' => some_options }.to_json)
The error I'm seeing in my production log looks like this:
Started PUT "/api/v2/users/3" for 1.2.3.4 at 2015-03-07 06:10:28 +0000
Processing by Api::V2::UsersController#update as JSON
Parameters: {"user"=>{"login"=>"admin", "auth_source_id"=>1,
"password"=>"[FILTERED]", "admin"=>true, "mail"=>"awesome.user@my.domain",
"firstname"=>"Awesome", "lastname"=>"User"}, "apiv"=>"v2", "id"=>"5"}
Authorized user awesome.user(Awesome User)
undefined method admin=' for nil:NilClass (NoMethodError) /usr/share/foreman/app/controllers/concerns/foreman/controller/users_mixin.rb:48:in
update_admin_flag'
Any thoughts on this? I checked users_mixin and it appears that the @user
object is nill, but that's about as far into debugging as I've made it.
Also, for what it's worth, it's not specific to this user. It happens with
any user any time I do a put or a post.
Thanks for the help.