我想使用restapi从VSTS中获取附件详细信息和测试用例的附件。
5.0中的哪个restapi可用于检索附件详细信息?
https://docs.microsoft.com/en-us/rest/api/vsts/?view=vsts-rest-5.0
我创建了一个PBI,添加了2个任务和2个测试,如下所示:
ID字段是WORKITEMID吗?
图1:
图2:
答案 0 :(得分:1)
测试用例是一种工作项类型,因此您可以使用Attachments - Get REST API。
下载附件:
GET https://dev.azure.com/{organization}/{project}/_apis/wit/attachments/{id}?api-version=5.0-preview.3
要获取attachment id
,可以将Get Work Item API与$expand=al
一起使用:
https://dev.azure.com/{organization}/{project}/_apis/wit/workitems/{workItemID}?api-version=5.0&$expand=all
您将在结果中获得ID(在url
部分的relations
中):
"relations":[
{
"rel":"AttachedFile",
"url":"https://shaykia.visualstudio.com/_apis/wit/attachments/xxxxx-4453-40b0-acaf-ace14902484c",
所以现在您有了附件ID:xxxxx-4453-40b0-acaf-ace14902484c
,要使用上面的API(instaed)下载附件:
https://dev.azure.com/{organization}/{project}/_apis/wit/attachments/xxxxx-4453-40b0-acaf-ace14902484c?api-version=5.0-preview.3