404 while creating new PR review

Hi,

I’m trying to use the PR review API for creating new reviews and new review comments.

The following request should work, but returns 404

❯ curl -X POST \
      -H "Accept: application/vnd.github.v3+json" -H "Authorization: token XXXXXXXX" \
      -H "Content-Type: application/json" \
      -d "{'body':'test', 'commit_id':'1b6897c66053c7fecf66853bdaea19a87b75c07b'}" \
      https://api.github.com/repos/andre15silva/failingProject/pulls/1/reviews
{
  "message": "Not Found",
  "documentation_url": "https://docs.github.com/rest/reference/pulls#create-a-review-for-a-pull-request"
}

I have also tried using the official library @octokit/request as well as the unofficial library (which has this implemented) hub4j/github-api and both return 404.

The related PR is NOMERGE: FL comments test PR by andre15silva · Pull Request #1 · andre15silva/failingProject · GitHub, which does exists and should be available.

Am I missing something?

Best
André

Hi,

So I finally found the issue. The token I was using didn’t have the permission public_repo, and so didn’t work.

This is really confusing tho, since the return code is 404 and no information about what permissions are required is given in the API documentation.

IMO, for this to be more user friendly, the required permissions should be explicit on the API documentation and the return code for the operation with a lack-privileged token should be 403.