Comments - Add

Add a comment on a work item.

POST https://dev.azure.com/{organization}/{project}/_apis/wit/workItems/{workItemId}/comments?api-version=5.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.

api-version
query True
  • string

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

Request Body

Name Type Description
text
  • string

The text of the comment.

Responses

Name Type Description
200 OK

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_write Grants the ability to read, create, and update work items and queries, update board metadata, read area and iterations paths other work item tracking related metadata, execute queries, and to receive notifications about work item events via service hooks.

Examples

Add a comment

Sample Request

POST https://dev.azure.com/fabrikam/Fabrikam-Fiber-Git/_apis/wit/workItems/299/comments?api-version=5.1-preview.3
[
  {
    "text": "Moving to the right area path"
  }
]

Sample Response

{
  "workItemId": 299,
  "commentId": 50,
  "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/50"
}

Definitions

Comment

Comment on a Work Item.

CommentCreate

Represents a request to create a work item comment.

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

Link references to related REST resources.

createdBy

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

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

The mentions of the comment.

modifiedBy

IdentityRef of the user who last modified the comment.

modifiedDate
  • string

The last modification date of the comment.

reactions

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.

CommentCreate

Represents a request to create a work item comment.

Name Type Description
text
  • string

The text of the comment.

CommentMention

Name Type Description
_links

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

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

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

IdentityRef

Name Type Description
_links

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.