Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do i get the list of Reviewers for a pull request using Github api?

I need the list of reviewers for a PR, and the Review Requests API present in Github only provides me the requested reviewers which becomes empty once the reviewers have accepted their invitations. I also tried the Reviews API to get all reviews and then get unique users, but that seems to be only for users who enter one and not for those who have accepted the request review invitation and never posted a review.

like image 529
Jeson Dias Avatar asked Jul 07 '17 07:07

Jeson Dias


People also ask

How do I fetch users from GitHub API?

To fetch a user we need: fetch('https://api.github.com/users/USERNAME') . If the response has status 200 , call . json() to read the JS object. Otherwise, if a fetch fails, or the response has non-200 status, we just return null in the resulting array.

How do I see review requests on GitHub?

Try the link https://github.com/pulls/review-requested, which shows you all Pull Requests that you've been tagged in as a reviewer. Note that you may have to click the Open or Closed buttons on that page to filter the Pull Requests you wish to see.


2 Answers

The way to get other reviewers is
https://api.github.com/repos/{owner}/{repo}/pulls/{pull_number}/reviews
You will get all actual reviews, and state will show is it APPROVED or CHANGES_REQUESTED. And each review also has a user

like image 191
TANDEROID Avatar answered Sep 19 '22 07:09

TANDEROID


Just went through this problem with the following solution.

According to GitHub's documentation:

GET /repos/:owner/:repo/pulls/:pull_number/requested_reviewers

Pull request authors and repository owners and collaborators can request a pull request review from anyone with write access to the repository. Each requested reviewer will receive a notification asking them to review the pull request.

Test Request:

https://api.github.com/repos/roliveiravictor/demo-rust-learning/pulls/1/requested_reviewers

Response:

{
    "users": [],
    "teams": []
}

Since nobody is settle on this public test repo, of course it's empty. Remember, they need to have write access on your repository. This worked pretty well on my private project.

like image 30
Victor R. Oliveira Avatar answered Sep 20 '22 07:09

Victor R. Oliveira