首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >github get_organization给出未找到的错误get_organization 404

github get_organization给出未找到的错误get_organization 404
EN

Stack Overflow用户
提问于 2021-05-12 17:22:18
回答 1查看 420关注 0票数 1

我在试着屏蔽一些github的回复。我有一个组织名单,我想要筛选。对一些人来说,它工作得很好,而对另一些人来说,即使它们确实存在,我也会得到404没有找到错误:

代码语言:javascript
复制
github_api = Github(github_access_token)
print(github_api.get_organization('eosforce').get_repos())
代码语言:javascript
复制
 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"}

例如,这可以很好地工作:

代码语言:javascript
复制
print(github_api.get_organization('bitcoin').get_repos())

有人知道问题在哪里吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-05-12 17:32:30

这里的问题似乎是,所有你想要得到回复的组织都不需要在Github上有一个organization account

例如:

  • 力场有一个Github user帐户。
  • 比特币有一个Github organization帐户。

因此,您使用的端点:https://docs.github.com/en/rest/reference/orgs#get-an-organization只适用于组织,它将返回一个未找到的带有用户帐户的组织的http状态(如力场)。

实现的第一步应该是检查您想要获得存储库的帐户是用户还是组织帐户。

然后,要获得用户存储库,请使用:

https://docs.github.com/rest/reference/repos#list-repositories-for-a-user

要获得组织存储库,请使用:

https://docs.github.com/rest/reference/repos#list-organization-repositories

有关如何在需要时使用这些端点的更多详细信息,请参见关于存储库的Github文档

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67508305

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档