Reputation: 73
I'm trying to Add/Remove assigned users to a pull request in a .NET 5 console app.
I'm using the library octokit.net and I'm able to get a PR and see the actual users assigned but it is a read-only collection and I can't find a way to update it.
the PullRequest.Update() method has only a few fields to update like title, body, and state but nothing else.
Any help would be appreciated, thanks!
Upvotes: 1
Views: 645
Reputation: 73
I found out how to implement this and leave the answer to help if someone has the same question.
In octokit.net you can get the assignees of a pull request through issues, even if you didn't create an issue in GitHub.
Example of adding and removing assignees:
var productInformation = new ProductHeaderValue("owner");
var credentials = new Credentials("your token");
var gitHubClient = new GitHubClient(productInformation) { Credentials = credentials };
await gitHubClient.Issue.Assignee.RemoveAssignees("owner", "name", PrNumber, new AssigneesUpdate(new List<string>() { "userLogin" }));
await gitHubClient.Issue.Assignee.AddAssignees("owner", "name", PrNumber, new AssigneesUpdate(new List<string>() { "userLogin" }));
Upvotes: 0