Setting Request Headers in Ruby Setting Request Headers in Ruby ruby ruby

Setting Request Headers in Ruby


The third parameter is the headers hash.

You can do what you want by:

response = RestClient.post(   url,   request,  :content_type => :json, :accept => :json, :'x-auth-key' => "mykey")


You can also do this

RestClient::Request.execute(   :method => :get or :post,   :url => your_url,   :headers => {key => value})


I had the same problem with Rest-Client (1.7.2) I need to put both params and HTTP headers.

I solved with this syntax:

params = {id: id, device: device, status: status}headers = {myheader: "giorgio"}RestClient.put url, params, headers

I hate RestClient :-)