Mr Giggles
Mr Giggles

Reputation: 2104

Getting exception when updating the reviewers of a Pull Request azure devOps

I have an active pull request in ADO, and want to update it using the API described here:

Azure Documentation

So far, I can successfully update the title of the Pull Request.

{
    "title": "Foo"
}

I now want to update the reviewers, here is the request I am patching:

{
    "reviewers": [
    {
      "id": "myValidGuid"
    }

   ]
}

However I'm getting the following 400 error returned:

{
"$id": "1",
"innerException": null,
"message": "Invalid argument value.\r\nParameter name: You can only update reviewers, descriptions, titles, merge status, and status.",
"typeName": "Microsoft.TeamFoundation.SourceControl.WebServer.InvalidArgumentValueException, Microsoft.TeamFoundation.SourceControl.WebServer",
"typeKey": "InvalidArgumentValueException",
"errorCode": 0,
"eventId": 0
}

I can't see what I've got wrong with my request?

Upvotes: 4

Views: 2106

Answers (1)

DenverDev
DenverDev

Reputation: 497

Based on the link you provided it looks like you are using the 'Pull Requests API' but you should actually be using the Pull Request Reviewers API.

Per the documentation, the reviewerID is actually in the URI parameter:

PUT https://dev.azure.com/fabrikam/_apis/git/repositories/3411ebc1-d5aa-464f-9615-0b527bc66719/pullRequests/22/reviewers/{reviewerId}?api-version=5.0

Upvotes: 3

Related Questions