问题描述
我正在尝试使用github rest api列出存储库的提交状态.
I am trying to list status of commits for a repository using github rest api.
存储库处于组织之下,并且是私有的.repos_url
是 https://api.github.com/orgs/mydummyorg/repos
The repository is under organisation and is private.
The repos_url
of which is https://api.github.com/orgs/mydummyorg/repos
具有访问权限的用户可以查看给定引用的提交状态:
Users with pull access can view commit statuses for a given ref:
GET /repos/:owner/:repo/commits/:ref/statuses
根据上面的api,是GET网址
As per the api above is the GET url
所以我的最终URL是repos_ulr + :owner/:repo/commits/:ref/statuses
So my final url will be repos_ulr + :owner/:repo/commits/:ref/statuses
如果我按如下所示进行卷曲,则表明未找到404
If I do the curl as below then it is giving 404 not found
curl -u "username" https://api.github.com/orgs/mydummyorg/repos/:owner:repos/commits/:ref/statuses
位置:
-
:owner
=用户名(我在git中的登录ID) -
:repos
='mydummyorg 下的存储库名称 -
:ref
=提交的阴影
:owner
= username (my login id in git):repos
= repository name under 'mydummyorg:ref
= sha of the commit`
我不知道我在做什么错.我的网址正确吗?
我为:owner
,:repos
和:ref
传递的值正确吗?
I don't know what am I doing wrong. Is my url proper?
And the value that I am passing for :owner
, :repos
, :ref
correct?
推荐答案
我所能看到的是:
- 在卷曲中,您提到的是:owner:repos而不是
:owner/:repos
(可能是您的问题是错字,或者您忘记了'/
') -
GET /repos/:owner/:repo/commits/:ref/statuses
表示特定参考的列表状态" API 应为
- in your curl, you mention :owner:repos instead of
:owner/:repos
(maybe a typo in your question, or you forgot a '/
') GET /repos/:owner/:repo/commits/:ref/statuses
means the "List Statuses for a specific Ref" API should be
https://api.github.com/ + /repos/:owner/:repo/commits/:ref/statuses
(不是/repos/:owner/:repo/commits/:ref/statuses
前面的orgs/mydummyorg/
)
最后,您需要在该私人仓库上注册为所有者或合作者,或者即使您通过完整的凭据(用户名+密码),答案也始终是404.
确保您未激活 2FA ,否则您的用户名+密码将无效(您需要使用 PAT-个人访问令牌-代替)
Finally, you need to be registered as the owner or collaborator on that private repo, or even if you do pass your complete credentials (username + password), the answer will always be 404.
Make sure you didn't activate 2FA, or your username+password wouldn't work (you would need to use a PAT -- Personal Access Token -- instead)
OP Bhavik Shah 详细信息:
这篇关于存储库处于组织状态时,Github Api列表提交状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!