Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a comment to a work item using Visual Studio Team Services REST API

Is it possible to add a comment to a work item in Visual Studio Team Services using the REST API?

I've checked the work item doc and fields doc but I couldn't see anything in the fields JSON which looked like it's the comments field.

The scenario I'm trying to achieve is CCing an email to Zapier and having the body of the email added as a comment on the work item in VSO.

like image 470
Kevin Kuszyk Avatar asked Sep 17 '14 16:09

Kevin Kuszyk


2 Answers

Following @tzachs tip, this is the API call to add a comment (or history entry in VSO jargon):

PATCH https://{account}.visualstudio.com/defaultcollection/_apis/wit/workitems/{id}?api-version=1.0-preview.2

JSON payload:

[  
  {
    "op": "add",
    "path": "/fields/System.History",
    "value": "Comment from VSO REST API"
  }
]

Note: If you want to add multiple comments, you need to issue separate patch requests, or else the last one "wins".

like image 97
Kevin Kuszyk Avatar answered Oct 11 '22 20:10

Kevin Kuszyk


The field you're looking for is 'History', see example here: http://www.visualstudio.com/integrate/reference/reference-vso-work-item-work-items-vsi#updateafield

like image 30
tzachs Avatar answered Oct 11 '22 19:10

tzachs