AZURE:通过 az board 工作项上传附件

标签 azure azure-rest-api

我有一个问题,我使用 CLI 工具自动执行了很多任务

az boards work-item relation show
az boards work-item show
az boards work-item update

但现在,我的疑问是,作为自动化的一部分,我需要上传一些工作项的附件,可以使用 CLI 来做到这一点吗?

搜索我发现了这个链接:

https://learn.microsoft.com/en-us/rest/api/azure/devops/wit/attachments/create?view=azure-devops-rest-7.0&tabs=HTTP#upload-a-text-file

但是我没有看到在哪里指定要上传文件的工作项 ID,有人遇到这种需要吗?

谢谢您,最诚挚的问候。

最佳答案

But I do not see where specify the work item ID where you want to upload the file, somebody face by this need?

是的,您可以分两步上传特定工作项目中的附件 -

首先使用以下 URL 创建附件文件

POST https://dev.azure.com/{organization}/{project}/_apis/wit/attachments?fileName=textAsFileAttachment.txt&api-version=7.0

这里的请求正文是“要上传的用户文本内容”

enter image description here

第二次使用以下 URL 将此附件添加到特定工作项

PATCH https://{instance}/{collection}/{project}/_apis/wit/workitems/{id}?api-version=5.0

请求正文-

在下面的请求正文中使用上面生成的 URL

[
{
"op": "add",
"path": "/relations/-",
"value": {
"rel": "AttachedFile",
"url": "https://dev.azure.com/{collection}/yyyyyyyy/_apis/wit/attachments/xxxxxxxxxxx?fileName=textAsFileAttachment.txt",
"attributes": {
"comment": "Spec for the work"
}
}
}
]

enter image description here

enter image description here

通过这种方式,您可以将附件上传到工作项

可以引用这个SO-ThreadMS docs以及

关于AZURE:通过 az board 工作项上传附件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76921939/

相关文章:

Azure Multi-Tenancy SAAS/PAAS?

azure - ADF 分页规则从 REST API 获取总行数并添加为结束条件

azure - 如何使用 Azure 应用程序配置 REST API

javascript - 如何设置队列输出的过期时间 - Azure function js

python - 在 Azure Devops 中使用 API 创建变量组

azure - 如何使用 REST API 列出 azure 存储库中包含内容的文件

Azure WAF 排除 - (RFI) 攻击

api - 采用 postman 语法的 Azure Cosmos DB 调用 api

azure - SQL Azure 重试逻辑框架 TransientFaultHandling 是否附带默认重试策略?