2

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?

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250

1 Answers1

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.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Yes forgot to add the '/' between :owner and :repos. The issue is with the repository which i was trying to access. The repository is not showing up in my list of repository because of which i am getting 404. I have commits on repository but still that repository is not showing up in my list of repository. Any reason why? But am able to commit and view the repo from browser. But in list of repository i am not able to find the new created repository , which i created under a organisation and is private – Bhavik Shah Oct 26 '15 at 05:39
  • "The repository is not showing up in my list of repository": What list of repos are you referring to? Because the one returned by `orgs/mydummyorg/repos/:owner:repos/commits/:ref/statuses` will always return 404, since that API combination does not exist, as I detail in my answer. – VonC Oct 26 '15 at 05:43
  • 1
    Hi, i am doing curl for this url https://api.github.com/repos/:owner/:repository/statuses/:ref. Here the repository is part of an organisation. When i do the curl it gives status not found. In owner name i am giving my github id. I tried giving repository owner id still giving same error 404 not found – Bhavik Shah Oct 27 '15 at 04:29
  • 1
    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. Thanks @VonC for all help. Appreciate it. :) – Bhavik Shah Oct 27 '15 at 10:57
  • @BhavikShah Great! I have included your comment in the answer for more visibility. – VonC Oct 27 '15 at 11:42