How can I send an HTTP PUT request in Ruby? How can I send an HTTP PUT request in Ruby? ruby ruby

How can I send an HTTP PUT request in Ruby?


require 'net/http'port = 8080host = "127.0.0.1"path = "/Application?key=apikey&id=id&option=enable"req = Net::HTTP::Put.new(path, initheader = { 'Content-Type' => 'text/plain'})req.body = "whatever"response = Net::HTTP.new(host, port).start {|http| http.request(req) }puts response.code

Larry's answer helped point me in the right direction. A little more digging helped me find a more elegant solution guided by this answer.

http = Net::HTTP.new('www.mywebsite.com', port)response = http.send_request('PUT', '/path/from/host?id=id&option=enable|disable')