I am trying to do a RestClient.put in Ruby for a highchart graphic but I see that this is not replicated. Also first I have a RestClient.post and works fine but the problem is then with the put. At the end I want to manage an exception because the put returns 302 but I want to manage it as OK. If then of the post I make de put manually with the restclient plugin in the browser works fine, for this I assume that the problem is in the script at the put.
This is the fragment;
date_post = Time.now
date_post = fecha_post.strftime("%Y-%m-%d")
date_unix = Time.now
date_unix = fecha_unix.strftime("%Y-%m-%d")
date_unix = (fecha_unix.to_time.to_i)
date_unix = fecha_unix.to_s + '000'
conversion = 50 #this is a example number
name_metric= "metric_example"
build_header = {:content_type => :json, :accept => :json, :Authorization=> "here_is_auth_id"}
url = "http://example.com/data.json"
params = <<-eos
{
"identifier":"#{name_metric}","date":"#{date_post}","value":[#{date_unix},[#{conversion}]]
}
eos
JSON.parse RestClient.post url, params, build_header
begin
JSON.parse RestClient.put 'http://example', params, {:content_type => :json}
rescue => e
e.response
end
Could you tell me why is not working correctly? Thanks in advance.