Pull Request Properties - Update
创建或更新拉取请求外部属性。 修补作可以 add
、replace
或 remove
。 对于 add
作,路径可以为空。 如果路径为空,则该值必须是键值对的列表。 对于 replace
作,路径不能为空。 如果路径不存在,则属性将添加到集合中。 对于 remove
作,路径不能为空。 如果路径不存在,则不会执行任何作。
PATCH https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/pullRequests/{pullRequestId}/properties?api-version=7.1
URI 参数
名称 | 在 | 必需 | 类型 | 说明 |
---|---|---|---|---|
organization
|
path | True |
string |
Azure DevOps 组织的名称。 |
pull
|
path | True |
integer (int32) |
拉取请求的 ID。 |
repository
|
path | True |
string |
拉取请求的目标分支的存储库 ID。 |
project
|
path |
string |
项目 ID 或项目名称 |
|
api-version
|
query | True |
string |
要使用的 API 版本。 这应设置为“7.1”才能使用此版本的 API。 |
请求正文
Media Types: "application/json-patch+json"
名称 | 类型 | 说明 |
---|---|---|
from |
string |
要从中复制移动/复制作的路径。 |
op |
修补作 |
|
path |
string |
作的路径。 对于数组,可以使用从零开始的索引来指定数组中的位置(例如 /biscuits/0/name)。 可以使用“-”字符而不是索引插入数组末尾(例如 /biscuits/-)。 |
value |
object |
作的值。 这是基元或 JToken。 |
响应
名称 | 类型 | 说明 |
---|---|---|
200 OK |
成功作 |
安全性
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 | 授予读取、更新和删除源代码、访问有关提交、更改集、分支和其他版本控制项目的元数据的能力。 此外,还授予创建和管理拉取请求和代码评审以及通过服务挂钩接收有关版本控制事件的通知的能力。 |
示例
Add properties |
Remove and replace properties |
Add properties
示例请求
PATCH https://dev.azure.com/fabrikam/_apis/git/repositories/{repositoryId}/pullRequests/{pullRequestId}/properties?api-version=7.1
[
{
"op": "add",
"path": "/sampleId",
"from": null,
"value": 8
},
{
"op": "add",
"path": "/startedDateTime",
"from": null,
"value": "2017-09-25T15:26:49.4760511Z"
},
{
"op": "add",
"path": "",
"from": null,
"value": {
"bytes": "dGhpcyBpcyBzYW1wbGUgYmFzZTY0IGVuY29kZWQgc3RyaW5n",
"globalId": "2c2ca1ab-a062-4329-83bd-33b2843c7d6d"
}
}
]
示例响应
{
"count": 6,
"value": {
"Microsoft.Git.PullRequest.SourceRefName": {
"$type": "System.String",
"$value": "refs/heads/vsts-api-sample/stage-range-cook"
},
"Microsoft.Git.PullRequest.TargetRefName": {
"$type": "System.String",
"$value": "refs/heads/master"
},
"sampleId": {
"$type": "System.String",
"$value": "8"
},
"startedDateTime": {
"$type": "System.DateTime",
"$value": "2017-09-25T15:26:49.477Z"
},
"bytes": {
"$type": "System.String",
"$value": "dGhpcyBpcyBzYW1wbGUgYmFzZTY0IGVuY29kZWQgc3RyaW5n"
},
"globalId": {
"$type": "System.String",
"$value": "2c2ca1ab-a062-4329-83bd-33b2843c7d6d"
}
}
}
Remove and replace properties
示例请求
PATCH https://dev.azure.com/fabrikam/_apis/git/repositories/{repositoryId}/pullRequests/{pullRequestId}/properties?api-version=7.1
[
{
"op": "replace",
"path": "/sampleId",
"from": null,
"value": 12
},
{
"op": "remove",
"path": "/startedDateTime",
"from": null,
"value": null
}
]
示例响应
{
"count": 3,
"value": {
"Microsoft.Git.PullRequest.SourceRefName": {
"$type": "System.String",
"$value": "refs/heads/vsts-api-sample/letter-field-verse"
},
"Microsoft.Git.PullRequest.TargetRefName": {
"$type": "System.String",
"$value": "refs/heads/master"
},
"sampleId": {
"$type": "System.String",
"$value": "12"
}
}
}
定义
名称 | 说明 |
---|---|
Json |
JSON 修补作的 JSON 模型 |
Operation |
修补作 |
Properties |
类将属性包表示为键值对的集合。 接受除 |
JsonPatchDocument
JSON 修补作的 JSON 模型
名称 | 类型 | 说明 |
---|---|---|
from |
string |
要从中复制移动/复制作的路径。 |
op |
修补作 |
|
path |
string |
作的路径。 对于数组,可以使用从零开始的索引来指定数组中的位置(例如 /biscuits/0/name)。 可以使用“-”字符而不是索引插入数组末尾(例如 /biscuits/-)。 |
value |
object |
作的值。 这是基元或 JToken。 |
Operation
修补作
值 | 说明 |
---|---|
add | |
copy | |
move | |
remove | |
replace | |
test |
PropertiesCollection
类将属性包表示为键值对的集合。 接受除 DBNull
以外的所有基元类型(具有 TypeCode != TypeCode.Object
的任何类型)的值。 Byte[]、Int32、Double、DateType 和 String 类型的值将保留其类型,其他基元将重新调整为 String。 Byte[] 应为 base64 编码字符串。
名称 | 类型 | 说明 |
---|---|---|
count |
integer (int32) |
集合中的属性计数。 |
item |
object |
|
keys |
string[] |
集合中的键集。 |
values |
string[] |
集合中的值集。 |