Created
June 13, 2011 17:13
-
-
Save kavu/1023207 to your computer and use it in GitHub Desktop.
Net::HTTP::Patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/http' | |
require 'json' | |
class Net::HTTP::Patch < Net::HTTPRequest | |
METHOD = 'PATCH' | |
REQUEST_HAS_BODY = true | |
RESPONSE_HAS_BODY = true | |
end | |
url = URI.parse('https://api.github.com/user') | |
req = Net::HTTP::Patch.new(url.path) | |
req.add_field("Authorization","token MY OAUTH TOKEN HERE") | |
http = Net::HTTP.new(url.host, url.port) | |
http.use_ssl = true | |
res = http.start { |h| h.request req, {:bio => "Some test bio"}.to_json } | |
puts res.body |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment