Share via


Git pull request reviewers

TFS 2017 | TFS 2015 | TFS 2013

Note

Looking for REST APIS that support TFS 2018 or later versions? See the Azure DevOps REST API Reference.

api-version = 3.0-preview

This API in preview. Learn more

If you haven't already, look at the information on getting started with these APIs.

The primary action for reviewers is to vote to approve or reject the pull request. Some reviewers are automatically added based on the policies set on the target branch of the pull request.

## Get a list of reviewers
GET https://{instance}/DefaultCollection/{project}/_apis/repos/git/repositories/{repository}/pullRequests/{pullRequest}/reviewers?api-version={version}
Parameter Type Notes
URL
instance string TFS server name ({server:port}).
project string ID or name of the project. Optional if specifying an ID for repository.
repository string ID of the repository.
pullRequest integer ID of the pull request.
Query
api-version string Version of the API to use.

Note

Repositories have both a name and an identifier. Identifiers are globally unique, but several projects may contain a repository of the same name. You don't need to include the project if you specify a repository by ID. However, if you specify a repository by name, you must also specify the project (by name or ID).

Sample request

GET https://mytfsserver/DefaultCollection/_apis/git/repositories/3411ebc1-d5aa-464f-9615-0b527bc66719/pullRequests/22/reviewers?api-version=3.0

Sample response

{
  "count": 1,
  "value": [
    {
      "reviewerUrl": "https://mytfsserver/DefaultCollection/_apis/git/repositories/3411ebc1-d5aa-464f-9615-0b527bc66719/pullRequests/22/reviewers/d6245f20-2af8-44f4-9451-8107cb2767db",
      "vote": 0,
      "id": "d6245f20-2af8-44f4-9451-8107cb2767db",
      "displayName": "Normal Paulk",
      "uniqueName": "fabrikamfiber16@hotmail.com",
      "url": "https://mytfsserver/DefaultCollection/_apis/Identities/d6245f20-2af8-44f4-9451-8107cb2767db",
      "imageUrl": "https://mytfsserver/DefaultCollection/_api/_common/identityImage?id=d6245f20-2af8-44f4-9451-8107cb2767db"
    }
  ]
}

Get a reviewer

GET https://{instance}/DefaultCollection/{project}/_apis/repos/git/repositories/{repository}/pullRequests/{pullRequest}/reviewers/{reviewer}?api-version={version}
Parameter Type Notes
URL
instance string TFS server name ({server:port}).
project string ID or name of the project. Optional if specifying an ID for repository.
repository string ID of the repository.
pullRequest integer ID of the pull request.
reviewer Guid ID of the reviewer. This can be retrieved from the Teams API or by getting a list of reviewers.
Query
api-version string Version of the API to use.

Sample request

GET https://mytfsserver/DefaultCollection/_apis/git/repositories/3411ebc1-d5aa-464f-9615-0b527bc66719/pullRequests/22/reviewers/19d9411e-9a34-45bb-b985-d24d9d87c0c9?api-version=3.0

Sample response

{
  "reviewerUrl": "https://mytfsserver/DefaultCollection/_apis/git/repositories/3411ebc1-d5aa-464f-9615-0b527bc66719/pullRequests/22/reviewers/19d9411e-9a34-45bb-b985-d24d9d87c0c9",
  "vote": 0,
  "id": "19d9411e-9a34-45bb-b985-d24d9d87c0c9",
  "displayName": "Johnnie McLeod",
  "uniqueName": "fabrikamfiber2@hotmail.com",
  "url": "https://mytfsserver/DefaultCollection/_apis/Identities/19d9411e-9a34-45bb-b985-d24d9d87c0c9",
  "imageUrl": "https://mytfsserver/DefaultCollection/_api/_common/identityImage?id=19d9411e-9a34-45bb-b985-d24d9d87c0c9"
}

Add a reviewer

Adds a reviewer and optionally sets their vote.

PUT https://{instance}/DefaultCollection/{project}/_apis/repos/git/repositories/{repository}/pullRequests/{pullRequest}/reviewers/{reviewer}?api-version={version}
{
    "vote": {integer}
}
Parameter Type Default Notes
URL
instance string TFS server name ({server:port}).
project string ID or name of the project. Optional if specifying an ID for repository.
repository string ID of the repository.
pullRequest integer ID of the pull request.
reviewer Guid ID of the reviewer.
Query
api-version string Version of the API to use.
Body
vote enum {-10, -5, 0, 5, 10} -10 means "Rejected", -5 means "Waiting for author", 0 means "No response", 5 means "Approved with suggestions", and 10 means "Approved".

Sample request

PUT https://mytfsserver/DefaultCollection/_apis/git/repositories/3411ebc1-d5aa-464f-9615-0b527bc66719/pullRequests/22/reviewers/19d9411e-9a34-45bb-b985-d24d9d87c0c9?api-version=3.0
{
  "vote": 0
}

Sample response

{
  "reviewerUrl": "https://mytfsserver/DefaultCollection/_apis/git/repositories/3411ebc1-d5aa-464f-9615-0b527bc66719/pullRequests/22/reviewers/19d9411e-9a34-45bb-b985-d24d9d87c0c9",
  "vote": 0,
  "id": "19d9411e-9a34-45bb-b985-d24d9d87c0c9",
  "displayName": "Johnnie McLeod",
  "uniqueName": "fabrikamfiber2@hotmail.com",
  "url": "https://mytfsserver/DefaultCollection/_apis/Identities/19d9411e-9a34-45bb-b985-d24d9d87c0c9",
  "imageUrl": "https://mytfsserver/DefaultCollection/_api/_common/identityImage?id=19d9411e-9a34-45bb-b985-d24d9d87c0c9"
}

Remove a reviewer

Removes a reviewer and their vote from a pull request.

DELETE https://{instance}/DefaultCollection/{project}/_apis/repos/git/repositories/{repository}/pullRequests/{pullRequest}/reviewers/{reviewer}?api-version={version}
Parameter Type Notes
URL
instance string TFS server name ({server:port}).
project string ID or name of the project. Optional if specifying an ID for repository.
repository string ID of the repository.
pullRequest integer ID of the pull request.
reviewer Guid ID of the reviewer.
Query
api-version string Version of the API to use.

Sample request

DELETE https://mytfsserver/DefaultCollection/_apis/git/repositories/3411ebc1-d5aa-464f-9615-0b527bc66719/pullRequests/22/reviewers/19d9411e-9a34-45bb-b985-d24d9d87c0c9?api-version=3.0

Update a reviewer's vote

PUT https://{instance}/DefaultCollection/{project}/_apis/repos/git/repositories/{repository}/pullRequests/{pullRequest}/reviewers/{reviewer}?api-version={version}
{
  "vote": {integer}
}
Parameter Type Notes
URL
instance string TFS server name ({server:port}).
project string ID or name of the project. Optional if specifying an ID for repository.
repository string ID of the repository.
pullRequest integer ID of the pull request.
reviewer Guid ID of the reviewer. Must be an actual user (not a team or group).
Query
api-version string Version of the API to use.
Body
vote enum {-10, -5, 0, 5, 10} -10 means "Rejected", -5 means "Waiting for author", 0 means "No response", 5 means "Approved with suggestions", and 10 means "Approved".

Sample request

PUT https://mytfsserver/DefaultCollection/_apis/git/repositories/3411ebc1-d5aa-464f-9615-0b527bc66719/pullRequests/22/reviewers/d6245f20-2af8-44f4-9451-8107cb2767db?api-version=3.0
{
  "vote": 10
}

Sample response

{
  "reviewerUrl": "https://mytfsserver/DefaultCollection/_apis/git/repositories/3411ebc1-d5aa-464f-9615-0b527bc66719/pullRequests/22/reviewers/d6245f20-2af8-44f4-9451-8107cb2767db",
  "vote": 10,
  "id": "d6245f20-2af8-44f4-9451-8107cb2767db",
  "displayName": "Normal Paulk",
  "uniqueName": "fabrikamfiber16@hotmail.com",
  "url": "https://mytfsserver/DefaultCollection/_apis/Identities/d6245f20-2af8-44f4-9451-8107cb2767db",
  "imageUrl": "https://mytfsserver/DefaultCollection/_api/_common/identityImage?id=d6245f20-2af8-44f4-9451-8107cb2767db"
}