Create comment on pull request

Yes, it is possible. The section of the API docs you are referencing relates to line comments (comments on specific lines of the commits in the pull req), and the docs say:

Pull Request Review Comments are comments on a portion of the unified diff. These are separate from Commit Comments (which are applied directly to a commit, outside of the Pull Request view), and Issue Comments (which do not reference a portion of the unified diff).

What you need are those Issue comments, which are explained at the top of this page:

The Pull Request API allows you to list, view, edit, create, and even merge pull requests. Comments on pull requests can be managed via the Issue Comments API.

So, in order to create a Pull Request comment, you actually need to create an Issue comment (since a pull request creates an issue to manage it). The page for Issue comments confirms this:

The Issue Comments API supports listing, viewing, editing, and creating comments on issues and pull requests.

So, the request you need to make is:

POST /repos/:owner/:repo/issues/:number/comments

How do you know which issue comment URL to POST to? Well, if you look at the response for getting a single pull request, you will see that it contains an attribute called _links, and that this attribute has a nested comments attribute. This is the URL which you should use for reading and creating pull request comments, the same one as to be used in the POST request above.


According to Ivan, I was able to do something like:

$ curl -s -H "Authorization: token ${ACCESS_TOKEN}" \
 -X POST -d '{"body": "Your Message to Comment"}' \
 "https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/issues/${PR_NUMBER}/comments"

or

$ curl -s -u "${GITHUB_ACCOUNT} \
 -X POST -d '{"body": "Your Message to Comment"}' \
 "https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/issues/${PR_NUMBER}/comments"

with password prompt