Search code examples
resttfstfs-sdkazure-devops-rest-api

How to get the list of test run attachments via TFS Client Libaries for REST API?


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?


Solution

  • 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