Using the GitHub API I am trying to add a comment to a file – not a specific line.
I’ve tried this:
HTTP POST https://api.github.com/repos/XXXX/YYYY/pulls/8/reviews
{
"body": "A general review comment",
"event": "APPROVE",
"comments": [
{
"subject_type": "file",
"path": "Program.cs",
"body": "This file is awsome!"
}
]
}
But I get this response
{
"message": "Unprocessable Entity",
"errors": [
"Variable $comments of type [DraftPullRequestReviewComment] was provided invalid value for 0.subjectType (Field is not defined on DraftPullRequestReviewComment), 0.position (Expected value to not be null)"
],
"documentation_url": "https://docs.github.com/rest/pulls/reviews#create-a-review-for-a-pull-request",
"status": "422"
}
The documentation is a bit inconclusive.
Under the “Create a review comment for a pull request” https://docs.github.com/en/rest/pulls/comments?apiVersion=2022-11-28#create-a-review-comment-for-a-pull-request it mentions the subject_type
But under “Create a review for a pull request” https://docs.github.com/rest/pulls/reviews#create-a-review-for-a-pull-request it does not mention the parameter.
So my question is:
With the GitHub Rest API, how do I add a review comment so a file? I d not want to comment on a specific line in a file.