Comments - Get Comments

Returns a list of work item comments, pageable.

GET https://dev.azure.com/{organization}/{project}/_apis/wit/workItems/{workItemId}/comments?api-version=6.0-preview.3
GET https://dev.azure.com/{organization}/{project}/_apis/wit/workItems/{workItemId}/comments?$top={$top}&continuationToken={continuationToken}&includeDeleted={includeDeleted}&$expand={$expand}&order={order}&api-version=6.0-preview.3

URI Parameters

Name In Required Type Description
organization
path True

string

The name of the Azure DevOps organization.

project
path True

string

Project ID or project name

workItemId
path True

integer

int32

Id of a work item to get comments for.

api-version
query True

string

Version of the API to use. This should be set to '6.0-preview.3' to use this version of the api.

$expand
query

CommentExpandOptions

Specifies the additional data retrieval options for work item comments.

$top
query

integer

int32

Max number of comments to return.

continuationToken
query

string

Used to query for the next page of comments.

includeDeleted
query

boolean

Specify if the deleted comments should be retrieved.

order
query

CommentSortOrder

Order in which the comments should be returned.

Responses

Name Type Description
200 OK

CommentList

successful operation

Security

oauth2

Type: oauth2
Flow: accessCode
Authorization URL: https://app.vssps.visualstudio.com/oauth2/authorize&response_type=Assertion
Token URL: https://app.vssps.visualstudio.com/oauth2/token?client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer&grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer

Scopes

Name Description
vso.work Grants the ability to read work items, queries, boards, area and iterations paths, and other work item tracking related metadata. Also grants the ability to execute queries, search work items and to receive notifications about work item events via service hooks.

Examples

Get the first page of comments
Get the next page of comments

Get the first page of comments

Sample Request

GET https://dev.azure.com/fabrikam/Fabrikam-Fiber-Git/_apis/wit/workItems/299/comments?$top=2&api-version=6.0-preview.3

Sample Response

{
  "totalCount": 10,
  "count": 2,
  "comments": [
    {
      "workItemId": 299,
      "commentId": 45,
      "version": 1,
      "text": "Johnnie is going to take this work over.",
      "createdBy": {
        "displayName": "Jamal Hartnett",
        "url": "https://vssps.dev.azure.com/fabrikam/_apis/Identities/d291b0c4-a05c-4ea6-8df1-4b41d5f39eff",
        "_links": {
          "avatar": {
            "href": "https://dev.azure.com/mseng/_apis/GraphProfile/MemberAvatars/aad.YTkzODFkODYtNTYxYS03ZDdiLWJjM2QtZDUzMjllMjM5OTAz"
          }
        },
        "id": "d291b0c4-a05c-4ea6-8df1-4b41d5f39eff",
        "uniqueName": "fabrikamfiber4@hotmail.com",
        "imageUrl": "https://dev.azure.com/fabrikam/_api/_common/identityImage?id=d291b0c4-a05c-4ea6-8df1-4b41d5f39eff",
        "descriptor": "aad.YTkzODFkODYtNTYxYS03ZDdiLWJjM2QtZDUzMjllMjM5OTAz"
      },
      "createdDate": "2019-01-21T20:12:14.683Z",
      "modifiedBy": {
        "displayName": "Jamal Hartnett",
        "url": "https://vssps.dev.azure.com/fabrikam/_apis/Identities/d291b0c4-a05c-4ea6-8df1-4b41d5f39eff",
        "_links": {
          "avatar": {
            "href": "https://dev.azure.com/mseng/_apis/GraphProfile/MemberAvatars/aad.YTkzODFkODYtNTYxYS03ZDdiLWJjM2QtZDUzMjllMjM5OTAz"
          }
        },
        "id": "d291b0c4-a05c-4ea6-8df1-4b41d5f39eff",
        "uniqueName": "fabrikamfiber4@hotmail.com",
        "imageUrl": "https://dev.azure.com/fabrikam/_api/_common/identityImage?id=d291b0c4-a05c-4ea6-8df1-4b41d5f39eff",
        "descriptor": "aad.YTkzODFkODYtNTYxYS03ZDdiLWJjM2QtZDUzMjllMjM5OTAz"
      },
      "modifiedDate": "2019-01-21T20:12:14.683Z",
      "isDeleted": false,
      "url": "https://dev.azure.com/fabrikam/6ce954b1-ce1f-45d1-b94d-e6bf2464ba2c/_apis/wit/workItems/299/comments/45"
    },
    {
      "workItemId": 299,
      "commentId": 44,
      "version": 1,
      "text": "Moving to the right area path",
      "createdBy": {
        "displayName": "Jamal Hartnett",
        "url": "https://vssps.dev.azure.com/fabrikam/_apis/Identities/d291b0c4-a05c-4ea6-8df1-4b41d5f39eff",
        "_links": {
          "avatar": {
            "href": "https://dev.azure.com/mseng/_apis/GraphProfile/MemberAvatars/aad.YTkzODFkODYtNTYxYS03ZDdiLWJjM2QtZDUzMjllMjM5OTAz"
          }
        },
        "id": "d291b0c4-a05c-4ea6-8df1-4b41d5f39eff",
        "uniqueName": "fabrikamfiber4@hotmail.com",
        "imageUrl": "https://dev.azure.com/fabrikam/_api/_common/identityImage?id=d291b0c4-a05c-4ea6-8df1-4b41d5f39eff",
        "descriptor": "aad.YTkzODFkODYtNTYxYS03ZDdiLWJjM2QtZDUzMjllMjM5OTAz"
      },
      "createdDate": "2019-01-20T23:26:33.383Z",
      "modifiedBy": {
        "displayName": "Jamal Hartnett",
        "url": "https://vssps.dev.azure.com/fabrikam/_apis/Identities/d291b0c4-a05c-4ea6-8df1-4b41d5f39eff",
        "_links": {
          "avatar": {
            "href": "https://dev.azure.com/mseng/_apis/GraphProfile/MemberAvatars/aad.YTkzODFkODYtNTYxYS03ZDdiLWJjM2QtZDUzMjllMjM5OTAz"
          }
        },
        "id": "d291b0c4-a05c-4ea6-8df1-4b41d5f39eff",
        "uniqueName": "fabrikamfiber4@hotmail.com",
        "imageUrl": "https://dev.azure.com/fabrikam/_api/_common/identityImage?id=d291b0c4-a05c-4ea6-8df1-4b41d5f39eff",
        "descriptor": "aad.YTkzODFkODYtNTYxYS03ZDdiLWJjM2QtZDUzMjllMjM5OTAz"
      },
      "modifiedDate": "2019-01-20T23:26:33.383Z",
      "isDeleted": false,
      "url": "https://dev.azure.com/fabrikam/6ce954b1-ce1f-45d1-b94d-e6bf2464ba2c/_apis/wit/workItems/299/comments/44"
    }
  ],
  "nextPage": "https://dev.azure.com/fabrikam/6ce954b1-ce1f-45d1-b94d-e6bf2464ba2c/_apis/wit/workItems/299/comments?continuationToken=DFkODYtNTYxYS03ZDdiLWJj&api-version=5.1-preview",
  "continuationToken": "DFkODYtNTYxYS03ZDdiLWJj"
}

Get the next page of comments

Sample Request

GET https://dev.azure.com/fabrikam/Fabrikam-Fiber-Git/_apis/wit/workItems/299/comments?continuationToken=DFkODYtNTYxYS03ZDdiLWJj&api-version=6.0-preview.3

Sample Response

{
  "totalCount": 10,
  "count": 2,
  "comments": [
    {
      "workItemId": 299,
      "commentId": 43,
      "version": 1,
      "text": "Johnnie is going to take this work over.",
      "createdBy": {
        "displayName": "Jamal Hartnett",
        "url": "https://vssps.dev.azure.com/fabrikam/_apis/Identities/d291b0c4-a05c-4ea6-8df1-4b41d5f39eff",
        "_links": {
          "avatar": {
            "href": "https://dev.azure.com/mseng/_apis/GraphProfile/MemberAvatars/aad.YTkzODFkODYtNTYxYS03ZDdiLWJjM2QtZDUzMjllMjM5OTAz"
          }
        },
        "id": "d291b0c4-a05c-4ea6-8df1-4b41d5f39eff",
        "uniqueName": "fabrikamfiber4@hotmail.com",
        "imageUrl": "https://dev.azure.com/fabrikam/_api/_common/identityImage?id=d291b0c4-a05c-4ea6-8df1-4b41d5f39eff",
        "descriptor": "aad.YTkzODFkODYtNTYxYS03ZDdiLWJjM2QtZDUzMjllMjM5OTAz"
      },
      "createdDate": "2019-01-17T02:03:12.88Z",
      "modifiedBy": {
        "displayName": "Jamal Hartnett",
        "url": "https://vssps.dev.azure.com/fabrikam/_apis/Identities/d291b0c4-a05c-4ea6-8df1-4b41d5f39eff",
        "_links": {
          "avatar": {
            "href": "https://dev.azure.com/mseng/_apis/GraphProfile/MemberAvatars/aad.YTkzODFkODYtNTYxYS03ZDdiLWJjM2QtZDUzMjllMjM5OTAz"
          }
        },
        "id": "d291b0c4-a05c-4ea6-8df1-4b41d5f39eff",
        "uniqueName": "fabrikamfiber4@hotmail.com",
        "imageUrl": "https://dev.azure.com/fabrikam/_api/_common/identityImage?id=d291b0c4-a05c-4ea6-8df1-4b41d5f39eff",
        "descriptor": "aad.YTkzODFkODYtNTYxYS03ZDdiLWJjM2QtZDUzMjllMjM5OTAz"
      },
      "modifiedDate": "2019-01-17T02:03:12.88Z",
      "isDeleted": false,
      "url": "https://dev.azure.com/fabrikam/6ce954b1-ce1f-45d1-b94d-e6bf2464ba2c/_apis/wit/workItems/299/comments/43"
    },
    {
      "workItemId": 299,
      "commentId": 42,
      "version": 1,
      "text": "Moving to the right area path",
      "createdBy": {
        "displayName": "Jamal Hartnett",
        "url": "https://vssps.dev.azure.com/fabrikam/_apis/Identities/d291b0c4-a05c-4ea6-8df1-4b41d5f39eff",
        "_links": {
          "avatar": {
            "href": "https://dev.azure.com/mseng/_apis/GraphProfile/MemberAvatars/aad.YTkzODFkODYtNTYxYS03ZDdiLWJjM2QtZDUzMjllMjM5OTAz"
          }
        },
        "id": "d291b0c4-a05c-4ea6-8df1-4b41d5f39eff",
        "uniqueName": "fabrikamfiber4@hotmail.com",
        "imageUrl": "https://dev.azure.com/fabrikam/_api/_common/identityImage?id=d291b0c4-a05c-4ea6-8df1-4b41d5f39eff",
        "descriptor": "aad.YTkzODFkODYtNTYxYS03ZDdiLWJjM2QtZDUzMjllMjM5OTAz"
      },
      "createdDate": "2019-01-16T03:03:28.97Z",
      "modifiedBy": {
        "displayName": "Jamal Hartnett",
        "url": "https://vssps.dev.azure.com/fabrikam/_apis/Identities/d291b0c4-a05c-4ea6-8df1-4b41d5f39eff",
        "_links": {
          "avatar": {
            "href": "https://dev.azure.com/mseng/_apis/GraphProfile/MemberAvatars/aad.YTkzODFkODYtNTYxYS03ZDdiLWJjM2QtZDUzMjllMjM5OTAz"
          }
        },
        "id": "d291b0c4-a05c-4ea6-8df1-4b41d5f39eff",
        "uniqueName": "fabrikamfiber4@hotmail.com",
        "imageUrl": "https://dev.azure.com/fabrikam/_api/_common/identityImage?id=d291b0c4-a05c-4ea6-8df1-4b41d5f39eff",
        "descriptor": "aad.YTkzODFkODYtNTYxYS03ZDdiLWJjM2QtZDUzMjllMjM5OTAz"
      },
      "modifiedDate": "2019-01-16T03:03:28.97Z",
      "isDeleted": false,
      "url": "https://dev.azure.com/fabrikam/6ce954b1-ce1f-45d1-b94d-e6bf2464ba2c/_apis/wit/workItems/299/comments/42"
    }
  ]
}

Definitions

Name Description
Comment

Comment on a Work Item.

CommentExpandOptions

Specifies the additional data retrieval options for work item comments.

CommentList

Represents a list of work item comments.

CommentMention
CommentReaction

Contains information about work item comment reaction for a particular reaction type.

CommentReactionType

Type of the reaction.

CommentSortOrder

Order in which the comments should be returned.

IdentityRef
ReferenceLinks

The class to represent a collection of REST reference links.

Comment

Comment on a Work Item.

Name Type Description
_links

ReferenceLinks

Link references to related REST resources.

createdBy

IdentityRef

IdentityRef of the creator of the comment.

createdDate

string

The creation date of the comment.

createdOnBehalfDate

string

Effective Date/time value for adding the comment. Can be optionally different from CreatedDate.

createdOnBehalfOf

IdentityRef

Identity on whose behalf this comment has been added. Can be optionally different from CreatedBy.

id

integer

The id assigned to the comment.

isDeleted

boolean

Indicates if the comment has been deleted.

mentions

CommentMention[]

The mentions of the comment.

modifiedBy

IdentityRef

IdentityRef of the user who last modified the comment.

modifiedDate

string

The last modification date of the comment.

reactions

CommentReaction[]

The reactions of the comment.

text

string

The text of the comment.

url

string

version

integer

The current version of the comment.

workItemId

integer

The id of the work item this comment belongs to.

CommentExpandOptions

Specifies the additional data retrieval options for work item comments.

Name Type Description
all

string

none

string

reactions

string

Include comment reactions.

renderedText

string

Include the rendered text (html) in addition to MD text.

renderedTextOnly

string

If specified, then ONLY rendered text (html) will be returned, w/o markdown. Supposed to be used internally from data provides for optimization purposes.

CommentList

Represents a list of work item comments.

Name Type Description
_links

ReferenceLinks

Link references to related REST resources.

comments

Comment[]

List of comments in the current batch.

continuationToken

string

A string token that can be used to retrieving next page of comments if available. Otherwise null.

count

integer

The count of comments in the current batch.

nextPage

string

Uri to the next page of comments if it is available. Otherwise null.

totalCount

integer

Total count of comments on a work item.

url

string

CommentMention

Name Type Description
_links

ReferenceLinks

Link references to related REST resources.

artifactId

string

The artifact portion of the parsed text. (i.e. the work item's id)

artifactType

string

The type the parser assigned to the mention. (i.e. person, work item, etc)

commentId

integer

The comment id of the mention.

targetId

string

The resolved target of the mention. An example of this could be a user's tfid

url

string

CommentReaction

Contains information about work item comment reaction for a particular reaction type.

Name Type Description
_links

ReferenceLinks

Link references to related REST resources.

commentId

integer

The id of the comment this reaction belongs to.

count

integer

Total number of reactions for the CommentReactionType.

isCurrentUserEngaged

boolean

Flag to indicate if the current user has engaged on this particular EngagementType (e.g. if they liked the associated comment).

type

CommentReactionType

Type of the reaction.

url

string

CommentReactionType

Type of the reaction.

Name Type Description
confused

string

dislike

string

heart

string

hooray

string

like

string

smile

string

CommentSortOrder

Order in which the comments should be returned.

Name Type Description
asc

string

The results will be sorted in Ascending order.

desc

string

The results will be sorted in Descending order.

IdentityRef

Name Type Description
_links

ReferenceLinks

This field contains zero or more interesting links about the graph subject. These links may be invoked to obtain additional relationships or more detailed information about this graph subject.

descriptor

string

The descriptor is the primary way to reference the graph subject while the system is running. This field will uniquely identify the same graph subject across both Accounts and Organizations.

directoryAlias

string

Deprecated - Can be retrieved by querying the Graph user referenced in the "self" entry of the IdentityRef "_links" dictionary

displayName

string

This is the non-unique display name of the graph subject. To change this field, you must alter its value in the source provider.

id

string

imageUrl

string

Deprecated - Available in the "avatar" entry of the IdentityRef "_links" dictionary

inactive

boolean

Deprecated - Can be retrieved by querying the Graph membership state referenced in the "membershipState" entry of the GraphUser "_links" dictionary

isAadIdentity

boolean

Deprecated - Can be inferred from the subject type of the descriptor (Descriptor.IsAadUserType/Descriptor.IsAadGroupType)

isContainer

boolean

Deprecated - Can be inferred from the subject type of the descriptor (Descriptor.IsGroupType)

isDeletedInOrigin

boolean

profileUrl

string

Deprecated - not in use in most preexisting implementations of ToIdentityRef

uniqueName

string

Deprecated - use Domain+PrincipalName instead

url

string

This url is the full route to the source resource of this graph subject.

The class to represent a collection of REST reference links.

Name Type Description
links

object

The readonly view of the links. Because Reference links are readonly, we only want to expose them as read only.