Rafael-WO
Rafael-WO

Reputation: 1630

TFS2017: Create a code review request through api

Is there any way to create a complete Code Review Request on a changeset (as it works through the Visual Studio Team Explorer -> with email to reviewer(s) who are able to comment the changes) using the .NET library Microsoft.TeamFoundationServer.Client?

P.S. Through my research I know it seems possible with the Microsoft.TeamFoundationServer.ExtendedClient using the Discussion Service, but I am looking for a solution using the "new" API.

Upvotes: 1

Views: 1760

Answers (1)

Cece Dong - MSFT
Cece Dong - MSFT

Reputation: 31023

You can start a code review by creating a code review request work item (use the general WIT api to create this type of WIT). Get a code review through REST API and look at the code review request work item that gets created to see how the fields need to be set. For example:

POST http://tfs2017:8080/tfs/DefaultCollection/{TeamProject}/_apis/wit/workitems/$Code%20Review%20Request?api-version=3.2

Content-Type: application/json-patch+json

  [
  {
    "op": "add",
    "path": "/fields/System.Title",
    "from": null,
    "value": "codereview452"
  },
  {
    "op": "add",
    "path": "/fields/System.State",
    "from": null,
    "value": "Requested"
  },
  {
    "op": "add",
    "path": "/fields/System.Reason",
    "from": null,
    "value": "New"
  },
  {
    "op": "add",
    "path": "/fields/Microsoft.VSTS.CodeReview.ContextType",
    "from": null,
    "value": "Changeset"
  },
   {
    "op": "add",
    "path": "/fields/Microsoft.VSTS.CodeReview.Context",
    "from": null,
    "value": "452"
  },
   {
    "op": "add",
    "path": "/fields/System.AssignedTo",
    "from": null,
    "value": "xxxx"
  },
   {
    "op": "add",
    "path": "/fields/Microsoft.VSTS.Common.StateCode",
    "from": null,
    "value": "0"
  },
  {
    "op": "add",
    "path": "/fields/Microsoft.VSTS.CodeReview.ContextCode",
    "from": null,
    "value": "2"
  }
]

The actual comments on the code review need to use the discussion service.

Upvotes: 1

Related Questions