如何使用 GitHub API 从 GitHub 拉取请求中获取评论?

How to get the comments from a GitHub pull request using GitHub API?

我正在尝试使用 GitHub API 获取对拉取请求的评论,例如:

https://api.github.com/repos/mapra99/members-only/pulls/1/comments

但它 returns 是一个空数组。

如果我尝试使用 review comments 端点,情况相同:

https://api.github.com/repos/mapra99/members-only/issues/1/comments

尽管对该拉取请求有评论:

https://github.com/mapra99/members-only/pull/1

如何使用 GitHub API 获取关于该拉取请求的评论?为什么无法从任何这些端点获取 if?

事实上,这不是评论而是 review :

Pull Request Reviews are groups of Pull Request Review Comments on the Pull Request, grouped together with a state and optional body comment.

您可以使用以下方式获取评论:

https://api.github.com/repos/mapra99/members-only/pulls/1/reviews

或使用 GraphQL v4 获取评论和评论:

{
  repository(owner: "mapra99", name: "members-only") {
    pullRequest(number: 1) {
      reviews(first: 100) {
        nodes {
          body
        }
      }
      comments(first: 100) {
        nodes {
          body
        }
      }
    }
  }
}