I am trying to do Http Basic Authentication with POST and nested parameters. While the outer parameters work fine (class.name - ActionController::Parameters) the nested parameters are string (class.name - String) Here is my code ->
require 'net/http'
uri = URI('http://example.com/bulb/')
req = Net::HTTP::Post.new(uri)
req.basic_auth '[email protected]', 'mypassword'
req.set_form_data('first_params' => 'a', 'seconnd_params'=>'b', 'netsed_params'=>{'first_netsed'=>'c', 'second_nested'=>'d'}, 'commit'=>'Create Bulb', 'action'=>'create', 'controller'=>'bulb')
res = Net::HTTP.start(uri.hostname, uri.port) do |http|
http.request(req)
end
case res
when Net::HTTPSuccess, Net::HTTPRedirection
# OK
else
#failed
end
What other library can I use to make the nested params work without having to manually convert them. I see that set_form_data doesn't work with nested hash