Skip to content

Instantly share code, notes, and snippets.

@chussenot
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chussenot/c5e13508365b44e1d108 to your computer and use it in GitHub Desktop.
Save chussenot/c5e13508365b44e1d108 to your computer and use it in GitHub Desktop.
require 'net/http'
require 'json'
uri = URI("https://api.github.com/gists")
payload = {
'description' => "My test gist",
'public' => true,
'files' => {
'test.txt' => {
'content' => Address.all.to_json
}
}
}
req = Net::HTTP::Post.new(uri.path)
req.body = payload.to_json
puts req.inspect
puts req.body.inspect
# GitHub API is strictly via HTTPS, so SSL is mandatory
res = Net::HTTP.start(uri.host, uri.port, :use_ssl => true) do |http|
http.request(req)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment