Share via


Work item comments

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

Every work item comment is associated with a single revision. This endpoint provides a way to interact with one or more comments for a given work item.

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

Get a single comment

GET https://{instance}/DefaultCollection/_apis/wit/workitems/{id}/comments/{revision}?api-version={version}
Parameter Type Default Notes
URL
instance string VS Team Services account ({account}.visualstudio.com) or TFS server ({server:port}).
id int ID of the work item.
revision int Revision number of the comment.
Query
api-version string Version of the API to use.

Sample request

GET https://mytfsserver/DefaultCollection/_apis/wit/workitems/299/comments/2?api-version=3.0-preview

Sample response

{
  "revision": 2,
  "text": "Moving to the right area path",
  "revisedBy": {
    "id": "d291b0c4-a05c-4ea6-8df1-4b41d5f39eff",
    "name": "Jamal Hartnett <fabrikamfiber4@hotmail.com>",
    "url": "https://mytfsserver/DefaultCollection/_apis/Identities/d291b0c4-a05c-4ea6-8df1-4b41d5f39eff"
  },
  "revisedDate": "2014-12-29T20:49:24.67Z",
  "url": "https://mytfsserver/DefaultCollection/_apis/wit/workItems/299/comments/2"
}

Sample code

Get a page of comments

GET https://{instance}/DefaultCollection/_apis/wit/workitems/{id}/comments?api-version={version}[&fromRevision={int}&$top={int}&order={order}]
Parameter Type Default Notes
URL
instance string VS Team Services account ({account}.visualstudio.com) or TFS server ({server:port}).
id int ID of the work item.
Query
api-version string Version of the API to use.
fromRevision integer 1 Starting revision ID to fetch comments from.
$top integer 200 Number of comments to fetch.
order enum { asc, desc} asc Revision number sort order.

Sample request

GET https://mytfsserver/DefaultCollection/_apis/wit/workitems/299/comments?fromRevision=2&$top=2&order=asc&api-version=3.0-preview

Sample response

{
  "totalCount": 5,
  "fromRevisionCount": 5,
  "count": 2,
  "value": [
    {
      "revision": 2,
      "text": "Moving to the right area path",
      "revisedBy": {
        "id": "d291b0c4-a05c-4ea6-8df1-4b41d5f39eff",
        "name": "Jamal Hartnett <fabrikamfiber4@hotmail.com>",
        "url": "https://mytfsserver/DefaultCollection/_apis/Identities/d291b0c4-a05c-4ea6-8df1-4b41d5f39eff"
      },
      "revisedDate": "2014-12-29T20:49:24.67Z",
      "url": "https://mytfsserver/DefaultCollection/_apis/wit/workItems/299/comments/2"
    },
    {
      "revision": 3,
      "text": "Johnnie is going to take this work over.",
      "revisedBy": {
        "id": "d291b0c4-a05c-4ea6-8df1-4b41d5f39eff",
        "name": "Jamal Hartnett <fabrikamfiber4@hotmail.com>",
        "url": "https://mytfsserver/DefaultCollection/_apis/Identities/d291b0c4-a05c-4ea6-8df1-4b41d5f39eff"
      },
      "revisedDate": "2014-12-29T20:49:26.99Z",
      "url": "https://mytfsserver/DefaultCollection/_apis/wit/workItems/299/comments/3"
    }
  ]
}

Sample code