Rest Api 以获取 VSTS 中测试用例的附件详细信息

RestApi to get attachment details for a testcase in VSTS

我想使用 restapi 从 VSTS 中获取附件详细信息和测试用例的附件。

5.0 中的哪个 restapi 用于检索附件详细信息?

https://docs.microsoft.com/en-us/rest/api/vsts/?view=vsts-rest-5.0

我创建了一个 PBI,添加了 2 个任务和 2 个测试,如下所示:

ID字段是WORKITEMID吗?

图一:

图2:

Test Case 是一种工作项类型,因此您可以使用 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(在 relations 部分的 url 中):

"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