Category Archives: REST

Sending A PUT request to the Server using Ruby on Rails

I have been trying for ages to find out how to send a PUT request to the server using ruby on rails. This page makes no fucking mention of a put() function. I cursed on many occasion.  Here it is. Hope this helps someone.

require ‘net/http’
url  = ‘/api/user.xml?id=6’
post_data = “<user><firstname>Freeman</firstname></user>”
http =‘’)
http.read_timeout = 300 # seconds
http.open_timeout = 180 # seconds
resp, data = http.put(url, post_data)