Share via


Comments - Get Comments Batch

Returns a list of work item comments by ids.

GET https://dev.azure.com/{organization}/{project}/_apis/wit/workItems/{workItemId}/comments?ids={ids}&api-version=6.1-preview.3
GET https://dev.azure.com/{organization}/{project}/_apis/wit/workItems/{workItemId}/comments?ids={ids}&includeDeleted={includeDeleted}&$expand={$expand}&api-version=6.1-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.1-preview.3' to use this version of the api.

ids
query True

string (array (int32))

Comma-separated list of comment ids to return.

$expand
query

CommentExpandOptions

Specifies the additional data retrieval options for work item comments.

includeDeleted
query

boolean

Specify if the deleted comments should be retrieved.

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 a list of comments by ids

Sample request

GET https://dev.azure.com/fabrikam/Fabrikam-Fiber-Git/_apis/wit/workItems/299/comments?ids=42,43&api-version=6.1-preview.3

Sample response

{
  "totalCount": 2,
  "count": 2,
  "comments": [
    {
      "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"
    },
    {
      "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"
    }
  ]
}

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.

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 (date-time)

The creation date of the comment.

createdOnBehalfDate

string (date-time)

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 (int32)

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 (date-time)

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 (int32)

The current version of the comment.

workItemId

integer (int32)

The id of the work item this comment belongs to.

CommentExpandOptions

Specifies the additional data retrieval options for work item comments.

Value Description
all
none
reactions

Include comment reactions.

renderedText

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

renderedTextOnly

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 (int32)

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 (int32)

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 (int32)

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 (int32)

The id of the comment this reaction belongs to.

count

integer (int32)

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.

Value Description
confused
dislike
heart
hooray
like
smile

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.