0

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.

  • Can you be more specific than "not working correctly" ? What happens ? – philant Aug 09 '13 at 17:18
  • The script ends well, the graphic has the value of the RestClient.post seeing it with a .get of the graphic, but the .put doesnt work because I cant see the new value. The RestClient.post save the value in the package_data but then I have to run the RestClient.put to see it, this is that is nor working. – user2668530 Aug 09 '13 at 18:29

0 Answers0