2013-01-21 114 views
1

出于某种原因,当我尝试发布githubs api创建存储库时,我一直得到404找不到。这是我的代码,有没有其他人经历过这个?Github API未找到404

url = "https://api.github.com/users/repo" 

headers = { 
    "Content-type" : "application/json", 
    "Authorization" : "token %s" % self.config['token'], 
} 

request = urllib2.Request(url, json.dumps(data), headers) 

try: 
    response = urllib2.urlopen(request).read() 
    # print response 
except Exception, e:  
    print e 

回答

2

您的网址有误;它是https://api.github.com/user/reposuser单数,repos复数),请参见Repos create documentation

+0

谢谢...愚蠢的错误可以真正让你有时。我的令牌上也有不当的管理权限... – JonMorehouse

+0

URL上的用户资源在此处是单数。文档现在显示'POST/user/repos'作为端点。自从创建此答案后,它一定发生了变化。为了将来的参考,当人们阅读今年的道路...这是API的第3版。 – Matt

+0

@Matt:这可能是我的错误;无论如何纠正以反映当前情况。 –