Pull Request Thread Comments - Create

在拉取请求中对特定线程创建注释(每个线程最多可以创建 500 条批注)。

POST https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/pullRequests/{pullRequestId}/threads/{threadId}/comments?api-version=7.1

URI 参数

名称 必需 类型 说明
organization
path True

string

Azure DevOps 组织的名称。

pullRequestId
path True

integer (int32)

拉取请求的 ID。

repositoryId
path True

string

拉取请求的目标分支的存储库 ID。

threadId
path True

integer (int32)

所需注释位于的线程的 ID。

project
path

string

项目 ID 或项目名称

api-version
query True

string

要使用的 API 版本。 这应设置为“7.1”才能使用此版本的 API。

请求正文

名称 类型 说明
_links

ReferenceLinks

指向其他相关对象的链接。

author

IdentityRef

注释的作者。

commentType

CommentType

创建时注释类型。

content

string

批注内容。

id

integer (int16)

注释 ID。 ID 从 1 开始,对拉取请求是唯一的。

isDeleted

boolean

此注释是否已软删除。

lastContentUpdatedDate

string (date-time)

评论内容上次更新的日期。

lastUpdatedDate

string (date-time)

上次更新批注的日期。

parentCommentId

integer (int16)

父注释的 ID。 这用于答复。

publishedDate

string (date-time)

首次发布批注的日期。

usersLiked

IdentityRef[]

喜欢此注释的用户的列表。

响应

名称 类型 说明
200 OK

Comment

成功作

安全性

oauth2

类型: oauth2
流向: accessCode
授权 URL: https://app.vssps.visualstudio.com/oauth2/authorize&response_type=Assertion
令牌 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

作用域

名称 说明
vso.code_write 授予读取、更新和删除源代码、访问有关提交、更改集、分支和其他版本控制项目的元数据的能力。 此外,还授予创建和管理拉取请求和代码评审以及通过服务挂钩接收有关版本控制事件的通知的能力。
vso.threads_full 授予读取和写入拉取请求注释线程的能力。

示例

示例请求

POST https://dev.azure.com/fabrikam/_apis/git/repositories/3411ebc1-d5aa-464f-9615-0b527bc66719/pullRequests/22/threads/148/comments?api-version=7.1

{
  "content": "Good idea",
  "parentCommentId": 1,
  "commentType": 1
}

示例响应

{
  "id": 2,
  "parentCommentId": 1,
  "author": {
    "id": "d6245f20-2af8-44f4-9451-8107cb2767db",
    "displayName": "Normal Paulk",
    "uniqueName": "fabrikamfiber16@hotmail.com",
    "url": "https://dev.azure.com/fabrikam/_apis/Identities/d6245f20-2af8-44f4-9451-8107cb2767db",
    "imageUrl": "https://dev.azure.com/fabrikam/_api/_common/identityImage?id=d6245f20-2af8-44f4-9451-8107cb2767db"
  },
  "content": "Good idea",
  "publishedDate": "2016-11-01T16:30:51.383Z",
  "lastUpdatedDate": "2016-11-01T16:30:51.383Z",
  "commentType": "text"
}

定义

名称 说明
Comment

表示一个批注,该批注是批注线程中可能存在的多个注释之一。

CommentType

创建时注释类型。

IdentityRef
ReferenceLinks

表示 REST 引用链接集合的类。

Comment

表示一个批注,该批注是批注线程中可能存在的多个注释之一。

名称 类型 说明
_links

ReferenceLinks

指向其他相关对象的链接。

author

IdentityRef

注释的作者。

commentType

CommentType

创建时注释类型。

content

string

批注内容。

id

integer (int16)

注释 ID。 ID 从 1 开始,对拉取请求是唯一的。

isDeleted

boolean

此注释是否已软删除。

lastContentUpdatedDate

string (date-time)

评论内容上次更新的日期。

lastUpdatedDate

string (date-time)

上次更新批注的日期。

parentCommentId

integer (int16)

父注释的 ID。 这用于答复。

publishedDate

string (date-time)

首次发布批注的日期。

usersLiked

IdentityRef[]

喜欢此注释的用户的列表。

CommentType

创建时注释类型。

说明
codeChange

由于代码更改,注释随之而来。

system

注释表示系统消息。

text

这是常规用户注释。

unknown

注释类型未知。

IdentityRef

名称 类型 说明
_links

ReferenceLinks

此字段包含有关图形主题的零个或多个有趣的链接。 可以调用这些链接以获取有关此图形主题的其他关系或更详细的信息。

descriptor

string

描述符是在系统运行时引用图形主题的主要方法。 此字段将唯一标识帐户和组织中的同一图形主题。

directoryAlias

string

已弃用 - 可以通过查询 IdentityRef“_links”字典的“self”条目中引用的 Graph 用户来检索

displayName

string

这是图形主题的非唯一显示名称。 若要更改此字段,必须在源提供程序中更改其值。

id

string

imageUrl

string

已弃用 - 在 IdentityRef“_links”字典的“虚拟形象”条目中可用

inactive

boolean

已弃用 - 可以通过查询 GraphUser“_links”字典的“membershipState”条目中引用的 Graph 成员身份状态来检索

isAadIdentity

boolean

已弃用 - 可以从描述符的主题类型推断(Descriptor.IsAadUserType/Descriptor.IsAadGroupType)

isContainer

boolean

已弃用 - 可以从描述符的主题类型推断(描述符.IsGroupType)

isDeletedInOrigin

boolean

profileUrl

string

已弃用 - 不在 ToIdentityRef 的大多数预先存在的实现中使用

uniqueName

string

已弃用 - 请改用 Domain+PrincipalName

url

string

此 URL 是指向此图形主题的源资源的完整路由。

表示 REST 引用链接集合的类。

名称 类型 说明
links

object

链接的只读视图。 由于引用链接是只读的,因此我们只想将其公开为只读链接。