python - github get_organization 给出 Not Found Error github.GithubException.UnknownObjectException: 404
问题描述
我正在尝试筛选一些 github 存储库。我有一个我想要筛选的组织列表。对于某些人来说它工作正常,对于其他人我得到 404 Not found 错误,即使它们实际上存在:
github_api = Github(github_access_token)
print(github_api.get_organization('eosforce').get_repos())
File "C:/Users/haase/Documents/VL/cryptodevel/create_repos.py", line 100, in <module>
print(github_api.get_organization('eosforce').get_repos())
File "C:\Users\haase\Documents\VL\pythonProject\lib\site-packages\github\MainClass.py", line 296, in get_organization
headers, data = self.__requester.requestJsonAndCheck("GET", f"/orgs/{login}")
File "C:\Users\haase\Documents\VL\pythonProject\lib\site-packages\github\Requester.py", line 353, in requestJsonAndCheck
return self.__check(
File "C:\Users\haase\Documents\VL\pythonProject\lib\site-packages\github\Requester.py", line 378, in __check
raise self.__createException(status, responseHeaders, output)
github.GithubException.UnknownObjectException: 404 {"message": "Not Found", "documentation_url": "https://docs.github.com/rest/reference/orgs#get-an-organization"}
例如,这很好用:
print(github_api.get_organization('bitcoin').get_repos())
有谁知道问题出在哪里?
解决方案
似乎这里的问题是,您想要获得 repos 的所有组织都不必organization account
在 Github 上拥有。
例如:
因此,您使用的端点:https://docs.github.com/en/rest/reference/orgs#get-an-organization
仅适用于组织,将为具有用户帐户的组织返回未找到的 http 状态(如eosforce)。
实施的第一步应该是检查您要获取存储库的帐户是用户帐户还是组织帐户。
然后,要获取用户存储库,请使用:
https://docs.github.com/rest/reference/repos#list-repositories-for-a-user
要获取组织存储库,请使用:
https://docs.github.com/rest/reference/repos#list-organization-repositories
有关如何使用这些端点(如果需要)的更多详细信息,请参阅有关存储库的 Github 文档。
推荐阅读
- python - 有没有使用 Google OAuth 提供程序执行代表登录的方法?
- javascript - URL 在 Postman 中有效,但在 Nodejs 中无效
- python - 惩罚线性回归的预测区间
- php - 如何将此 sql-injection-susceptible 函数转换为 MySQLi 中的准备函数?
- git - 如何使用 git 获取完整的 repo 副本
- rust - 为什么 Rust 借用检查器会忽略函数参数中的可变指针?
- python - Python -m 切换运行包内的模块
- android - 评估项目“:app”时出现问题 - Firebase 与 Flutter 集成
- html - 有没有办法我可以使用嵌入视频
- kepler.gl - 在没有互联网连接的笔记本电脑上运行 kepler.gl