Test attachments
TFS 2017 | TFS 2015 | TFS 2013
Note
Looking for REST APIS that support TFS 2018 or later versions? See the Azure DevOps REST API Reference.
api-version = 2.0-preview.1
If you haven't already, look at the information on getting started with these APIs.
Attach a file to a test run
POST https://{instance}/DefaultCollection/{project}/_apis/test/runs/{run}/attachments?api-version={version}
Content-Type: application/json
{
"stream": { string },
"fileName": { string },
"comment": { string },
"attachmentType": { string }
}
Parameter | Type | Default | Notes |
---|---|---|---|
URL | |||
instance | string | TFS server name ({server:port}). | |
project | string | Name or ID of the project. | |
run | int | ID of the test run against which attachment has to be uploaded. | |
Query | |||
api-version | string | Version of the API to use. | |
Body | |||
stream | string | Base64 encoded file stream | |
fileName | string | Attachment filename | |
comment | string | Comment associated with attachment | |
attachmentType | enum { GeneralAttachment, AfnStrip, BugFilingData, CodeCoverage, IntermediateCollectorData, RunConfig, TestImpactDetails, TmiTestRunDeploymentFiles, TmiTestRunReverseDeploymentFiles, TmiTestResultDetail, TmiTestRunSummary } | GeneralAttachment | Attachment type |
Sample request
POST https://mytfsserver/DefaultCollection/Fabrikam/_apis/test/runs/49/attachments?api-version=2.0-preview
{
"stream": "iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAIAAABvFaqvAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAABlSURBVDhP7cxBCsAgDERR739pG/CnGJI0FopQ8O2cjNP6R85QbeNQU7wT1dkijaQ3vkZoWElaoTeJojW01cYh0jwfgiFBV/lEjOZtacijN/nLkOBHhIaVDgn+Wdycp6FXzlCl9wt0Y0cAzHo/zgAAAABJRU5ErkJggg==",
"fileName": "imageAsFileAttachment.png",
"comment": "Test attachment upload",
"attachmentType": "GeneralAttachment"
}
Sample response
{
"id": 3,
"url": "https://mytfsserver/DefaultCollection/Fabrikam/_apis/test/Runs/49/Attachments/3"
}
Attach a file to a test result
POST https://{instance}/DefaultCollection/{project}/_apis/test/runs/{run}/results/{result}/attachments?api-version={version}
Content-Type: application/json
{
"stream": { string },
"fileName": { string },
"comment": { string },
"attachmentType": { string }
}
Parameter | Type | Default | Notes |
---|---|---|---|
URL | |||
instance | string | TFS server name ({server:port}). | |
project | string | Name or ID of the project. | |
run | int | ID of the test run that contains the result. | |
result | int | ID of the test results against which attachment has to be uploaded. | |
Query | |||
api-version | string | Version of the API to use. | |
Body | |||
stream | string | Base64 encoded file stream | |
fileName | string | Attachment filename | |
comment | string | Comment associated with attachment | |
attachmentType | enum { GeneralAttachment, AfnStrip, BugFilingData, CodeCoverage, IntermediateCollectorData, RunConfig, TestImpactDetails, TmiTestRunDeploymentFiles, TmiTestRunReverseDeploymentFiles, TmiTestResultDetail, TmiTestRunSummary } | GeneralAttachment | Attachment type |
Sample request
POST https://mytfsserver/DefaultCollection/Fabrikam/_apis/test/runs/49/results/100000/attachments?api-version=2.0-preview
{
"stream": "VXNlciB0ZXh0IGNvbnRlbnQgdG8gdXBsb2FkLg==",
"fileName": "textAsFileAttachment.txt",
"comment": "Test attachment upload",
"attachmentType": "GeneralAttachment"
}
Sample response
{
"id": 4,
"url": "https://mytfsserver/DefaultCollection/Fabrikam/_apis/test/Runs/49/Results/100000/Attachments/4"
}
Download a test run attachment
GET https://{instance}/DefaultCollection/{project}/_apis/test/runs/{run}/attachments/{attachment}?api-version={version}
Parameter | Type | Default | Notes |
---|---|---|---|
URL | |||
instance | string | TFS server name ({server:port}). | |
project | string | Name or ID of the project. | |
run | int | ID of the test run whose attachment has to be downloaded. | |
attachment | int | ID of the test run attachment to be downloaded | |
Query | |||
api-version | string | Version of the API to use. |
Sample request
GET https://fabrikam-fiber-inc:8080/DefaultCollection/fabrikam/_apis/test/runs/1/attachments/1?api-version=2.0-preview
Response
Status code: 200
{ file-contents }
Note
The response from this call will be the file itself (.jpeg, .json, etc.)
Download a test result attachment
GET https://{instance}/DefaultCollection/{project}/_apis/test/runs/{run}/results/{result}/attachments/{attachment}?api-version={version}
Parameter | Type | Default | Notes |
---|---|---|---|
URL | |||
instance | string | TFS server name ({server:port}). | |
project | string | Name or ID of the project. | |
run | int | ID of the test run that contains the result. | |
result | int | ID of the test result whose attachment has to be downloaded | |
attachment | int | ID of the test result attachment to be downloaded | |
Query | |||
api-version | string | Version of the API to use. |
Sample request
GET https://fabrikam-fiber-inc:8080/DefaultCollection/fabrikam/_apis/test/runs/1/results/100000/attachments/1?api-version=2.0-preview
Response
Status code: 200
{ file-contents }
Note
The response from this call will be the file itself (.jpeg, .json, etc.)
Get list of test run attachments
GET https://{instance}/DefaultCollection/{project}/_apis/test/runs/{run}/attachments?api-version={version}
Parameter | Type | Default | Notes |
---|---|---|---|
URL | |||
instance | string | TFS server name ({server:port}). | |
project | string | Name or ID of the project. | |
run | int | ID of the test run whose attachment has to be downloaded. | |
Query | |||
api-version | string | Version of the API to use. |
Sample request
GET https://mytfsserver/DefaultCollection/Fabrikam-Fiber-TFVC/_apis/test/runs/23/attachments?api-version=3.0-preview
Sample response
{
"count": 1,
"value": [
{
"createdDate": "2016-07-13T13:09:44.89Z",
"url": "https://mytfsserver/DefaultCollection/Fabrikam-Fiber-TFVC/_apis/test/Runs/23/Attachments/18",
"id": 18,
"fileName": "imageAsFileAttachment.png",
"comment": "Test attachment upload"
}
]
}
Get list of test result attachments
GET https://{instance}/DefaultCollection/{project}/_apis/test/runs/{run}/results/{result}/attachments?api-version={version}
Parameter | Type | Default | Notes |
---|---|---|---|
URL | |||
instance | string | TFS server name ({server:port}). | |
project | string | Name or ID of the project. | |
run | int | ID of the test run that contains the result. | |
result | int | ID of the test result whose attachment has to be downloaded | |
Query | |||
api-version | string | Version of the API to use. |
Sample request
GET https://mytfsserver/DefaultCollection/Fabrikam-Fiber-TFVC/_apis/test/runs/23/results/100000/attachments?api-version=3.0-preview
Sample response
{
"count": 1,
"value": [
{
"createdDate": "2016-07-13T13:09:45.427Z",
"url": "https://mytfsserver/DefaultCollection/Fabrikam-Fiber-TFVC/_apis/test/Runs/23/Results/100000/Attachments/19",
"id": 19,
"fileName": "textAsFileAttachment.txt",
"comment": "Test attachment upload"
}
]
}