Github Api list commit status when repository is under organisation

◇◆丶佛笑我妖孽 提交于 2019-12-22 18:27:58

问题


I am trying to list status of commits for a repository using github rest api.

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

As per the api above is the GET url

So my final url will be repos_ulr + :owner/:repo/commits/:ref/statuses

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

Where:

  • :owner = username (my login id in git)
  • :repos = repository name under 'mydummyorg
  • :ref = sha of the commit`

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?


回答1:


All I can see is:

  • 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
    

(not orgs/mydummyorg/ in front of /repos/:owner/:repo/commits/:ref/statuses)

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)

The OP Bhavik Shah details in the comments:

I was able to resolve the issue.
The owner detail that I was passing was wrong. It should be organisation name under which the repository is present.



来源:https://stackoverflow.com/questions/33326591/github-api-list-commit-status-when-repository-is-under-organisation

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!