Github API 发布未找到 404

1 投票
1 回答
2557 浏览
提问于 2025-04-17 13:19

出于某种原因,当我尝试使用 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

1 个回答

2

你输入的网址不对,正确的网址是 https://api.github.com/user/repos(这里的 user 是单数,repos 是复数)。你可以查看 创建仓库的文档 来了解更多信息。

撰写回答