There is a method TestManagementHttpClient.GetTestRunAttachmentContentAsync()
and it requires attachment id among other parameters but I couldn't find a method to get the list of all files attached to the test run so I'm wondering if there is a method for this?
Asked
Active
Viewed 1,477 times
0
3 Answers
3
You can use the undocumented (legacy?) API:
http://{server}/{collection}/{Team project}/_api/_testrun/GetTestRunAttachments?testRunId={testid}
This returns a an array. Be aware that this API might change in the future, though:
{
"__wrappedArray": [{
"__type": "TestRunAttachmentModel:#Microsoft.TeamFoundation.Server.WebAccess.TestManagement",
"attachmentComment": "",
"attachmentCreationDate": "\/Date(1467360776123)\/",
"attachmentId": 1233,
"attachmentName": "xy 2016-07-01 10_07_03.trx",
"attachmentSize": 6800374
},
{
"__type": "TestRunAttachmentModel:#Microsoft.TeamFoundation.Server.WebAccess.TestManagement",
"attachmentComment": "",
"attachmentCreationDate": "\/Date(1467360782220)\/",
"attachmentId": 1234,
"attachmentName": "xy 2016-07-01 10_05_50.coverage",
"attachmentSize": 7426581
}]
}
Hope this helps

blackbuild
- 5,026
- 1
- 23
- 35
0
You can download a test run attachment via Rest API. More details please refer Download a test run attachment in Test attachments.
Sample request

Community
- 1
- 1

PatrickLu-MSFT
- 49,478
- 5
- 35
- 62
-
I need the list of all attachments so i can pick the one i need. – Dmytro I. May 17 '16 at 13:12
-
This can't be achieved through rest api for now. You will have to know the ID of the test run attachment to be downloaded. And only download the one you specified with ID. – PatrickLu-MSFT May 17 '16 at 15:59
-
Is this feature in your backlog? – Dmytro I. May 17 '16 at 16:11
-
Can't find related info in https://www.visualstudio.com/en-us/news/release-archive-vso.aspx . Suggest you to add a feature request with https://visualstudio.uservoice.com/forums/330519-team-services , TFS Administrator will kindly review it. – PatrickLu-MSFT May 18 '16 at 08:18
0
There isn't any way to get all attachments directly via Rest API for now, you can submit a feature request on VSTS User Voice.
But if you use .NET Client Libraries, you can get all attachments from "ITestRun.Attachments". See following code for reference:
using System;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.TestManagement.Client;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string pu = "http://yourtfsserverurl";
string projectname = "projectname";
int testrunid = 1;//ID of test run
TfsTeamProjectCollection ttpc = new TfsTeamProjectCollection(new Uri(pu));
ITestManagementService itms = ttpc.GetService<ITestManagementService>();
ITestManagementTeamProject itmtp = itms.GetTeamProject(projectname);
ITestRun itr = itmtp.TestRuns.Find(testrunid);
foreach (ITestAttachment ita in itr.Attachments)
{
Console.WriteLine(ita.Name);
}
Console.ReadLine();
}
}
}

Eddie Chen - MSFT
- 29,708
- 2
- 46
- 60
-
Yes I know. I wanted to switch to REST. Thank you for your responses. – Dmytro I. May 18 '16 at 06:39