Add `Authorization Bearer` hash to Net::HTTP post request (Ruby)
I dont think you can add custom headers with the post_form
method. You can add it with post method. Try the code below:
uri = URI("http://localhost:8080/places")params = [{'uuid': '0514b...', 'name':'Athens'}]headers = { 'Authorization'=>'Bearer foobar', 'Content-Type' =>'application/json', 'Accept'=>'application/json'}http = Net::HTTP.new(uri.host, uri.port)response = http.post(uri.path, params.to_json, headers)