Reputation: 14275
I'm trying to send a POST request to the GitHub API to submit a comment on a commit.
According to the documentation, all that's needed (other than the URL params) is the body
.
I have modified the example from the docs to the following:
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/dchacke/test/commits/9b7413350932dd3f2906c0fdd26106c35c7ce450/comments \
-d '{"body":"test comment"}'
That should post a test comment to this commit. I know the commit and the owner and repo exist (it's my repo and I can see the commit under that URL), and yet I'm getting a 404 with the following response body upon submitting that API request:
{
"message": "Not Found",
"documentation_url": "https://docs.github.com/rest/reference/repos#create-a-commit-comment"
}
The documentation makes no mention of authentication being required for that endpoint. A 404 doesn't exactly sound like an authentication problem, but just in case GitHub doesn't want to confirm the existence of repos/commits to unauthenticated users (though they do let them see those things on their website...), I tried setting a personal access token in an additional Authorization
header in my CURL request. No dice.
What am I doing wrong?
Upvotes: 5
Views: 6510
Reputation: 14275
Authentication was the issue after all. I had to make sure I used a token with the right privileges. In this case, it needed the public_repo
privilege, which can be set up here.
Upvotes: 4