Permalink
Browse files

Adding request.body= example.

  • Loading branch information...
1 parent ea3b439 commit c714152d8d443198ab3d104c8fbada28c1ab228b @augustl committed May 12, 2011
Showing with 8 additions and 5 deletions.
  1. +8 −5 methods_and_rest.rb
View
@@ -6,16 +6,19 @@
request = Net::HTTP::Post.new("/users")
request.set_form_data({"users[login]" => "quentin"})
-response = http.request(request)
-# Use nokogiri, hpricot, etc to parse response.body.
+# or
+request.body = '{"username":"quentin"}'
+response = http.request(request) # Use nokogiri, hpricot, etc to parse response.body.
+
request = Net::HTTP::Get.new("/users/1")
-response = http.request(request)
-# As with POST, the data is in response.body.
+response = http.request(request) # As with POST, the data is in response.body.
+
request = Net::HTTP::Put.new("/users/1")
request.set_form_data({"users[login]" => "changed"})
response = http.request(request)
+
request = Net::HTTP::Delete.new("/users/1")
-response = http.request(request)
+response = http.request(request)

0 comments on commit c714152

Please sign in to comment.