我可以通过API检索GitHub PR审查状态吗?
我不想检索审查的“状态”(例如“打开”、“关闭”),而是检索状态(例如“批准”)。然而,我无法通过API实现这一点。无论状态如何,它总是返回一个空JSON数组 例如,此u应返回“已批准”状态,但不返回任何内容: 结果: [ ]我可以通过API检索GitHub PR审查状态吗?,github,github-api,Github,Github Api,我不想检索审查的“状态”(例如“打开”、“关闭”),而是检索状态(例如“批准”)。然而,我无法通过API实现这一点。无论状态如何,它总是返回一个空JSON数组 例如,此u应返回“已批准”状态,但不返回任何内容: 结果: [ ] API是否不支持此操作(“查看状态”)?您实际上应该尝试其他API。根据GitHub的报告 status API允许外部服务使用错误、失败、挂起、或成功状态标记提交,然后在涉及这些提交的请求中反映出来 因此,状态API将每个提交的状态作为PR的一部分提供,例如,如果构建
API是否不支持此操作(“查看状态”)?您实际上应该尝试其他API。根据GitHub的报告 status API允许外部服务使用
错误
、失败
、挂起
、或成功
状态标记提交,然后在涉及这些提交的请求中反映出来
因此,状态API将每个提交的状态作为PR的一部分提供,例如,如果构建失败或成功作为提交推送的一部分。下面的请求将仅作为引用的一部分返回状态
GET /repos/:owner/:repo/commits/:ref/statuses
您需要的是评论API,您可以从中获取PR的评论,其中包含您期望的状态
字段。API是
GET /repos/:owner/:repo/pulls/:number/reviews
下面是一个示例响应
[
{
"id": 80,
"node_id": "MDE3OlB1bGxSZXF1ZXN0UmV2aWV3ODA=",
"user": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"body": "Here is the body for the review.",
"commit_id": "ecdd80bb57125d7ba9641ffaa4d7d2c19d3f3091",
"state": "APPROVED",
"html_url": "https://github.com/octocat/Hello-World/pull/12#pullrequestreview-80",
"pull_request_url": "https://api.github.com/repos/octocat/Hello-World/pulls/12",
"_links": {
"html": {
"href": "https://github.com/octocat/Hello-World/pull/12#pullrequestreview-80"
},
"pull_request": {
"href": "https://api.github.com/repos/octocat/Hello-World/pulls/12"
}
}
}
]
请注意,响应中的状态字段具有您正在寻找的已批准状态
在API评论中提供更多信息。好的,太好了-感谢您提供的信息!看起来这样就行了!