Skip to content

Instantly share code, notes, and snippets.

@runemadsen
Created October 30, 2011 01:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save runemadsen/1325353 to your computer and use it in GitHub Desktop.
Save runemadsen/1325353 to your computer and use it in GitHub Desktop.
Creating a repo via the Github API and HTTParty
class Github
include HTTParty
base_uri 'https://api.github.com'
end
Github.post("/user/repos", :query => {
:access_token => @token
},
:body => {
:name => name,
:description => "Reop description",
:homepage => "http://mysite.com",
:public => true,
:has_issues => false,
:has_wiki => false,
:has_downloads => false
}.to_json)
@uri
Copy link

uri commented Jun 25, 2012

Why does body need the .to_json?

@steve0hh
Copy link

@uri sorry this came 2 years late..
For POST, PATCH, PUT, and DELETE requests, parameters not included in the URL should be encoded as JSON with a Content-Type of ‘application/json’:

according to github api

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment