Attachments - Create Test Result Attachment

Attach a file to a test result.

POST https://dev.azure.com/{organization}/{project}/_apis/test/Runs/{runId}/Results/{testCaseResultId}/attachments?api-version=5.1-preview.1

URI Parameters

Name In Required Type Description
organization
path True

string

The name of the Azure DevOps organization.

project
path True

string

Project ID or project name

runId
path True

integer

int32

ID of the test run that contains the result.

testCaseResultId
path True

integer

int32

ID of the test result against which attachment has to be uploaded.

api-version
query True

string

Version of the API to use. This should be set to '5.1-preview.1' to use this version of the api.

Request Body

Name Type Description
attachmentType

string

Attachment type By Default it will be GeneralAttachment. It can be one of the following type. { GeneralAttachment, AfnStrip, BugFilingData, CodeCoverage, IntermediateCollectorData, RunConfig, TestImpactDetails, TmiTestRunDeploymentFiles, TmiTestRunReverseDeploymentFiles, TmiTestResultDetail, TmiTestRunSummary }

comment

string

Comment associated with attachment

fileName

string

Attachment filename

stream

string

Base64 encoded file stream

Responses

Name Type Description
200 OK

TestAttachmentReference

successful operation

Security

oauth2

Type: oauth2
Flow: accessCode
Authorization URL: https://app.vssps.visualstudio.com/oauth2/authorize&response_type=Assertion
Token URL: https://app.vssps.visualstudio.com/oauth2/token?client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer&grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer

Scopes

Name Description
vso.test_write Grants the ability to read, create, and update test plans, cases, results and other test management related artifacts.

Examples

Sample Request

POST https://dev.azure.com/fabrikam/Fabrikam/_apis/test/Runs/49/Results/100000/attachments?api-version=5.1-preview.1

{
  "stream": "VXNlciB0ZXh0IGNvbnRlbnQgdG8gdXBsb2FkLg==",
  "fileName": "textAsFileAttachment.txt",
  "comment": "Test attachment upload",
  "attachmentType": "GeneralAttachment"
}

Sample Response

{
  "id": 4,
  "url": "https://dev.azure.com/fabrikam/Fabrikam/_apis/test/Runs/49/Results/100000/Attachments/4"
}

Definitions

Name Description
TestAttachmentReference

Reference to test attachment.

TestAttachmentRequestModel

Test attachment request model

TestAttachmentReference

Reference to test attachment.

Name Type Description
id

integer

ID of the attachment.

url

string

Url to download the attachment.

TestAttachmentRequestModel

Test attachment request model

Name Type Description
attachmentType

string

Attachment type By Default it will be GeneralAttachment. It can be one of the following type. { GeneralAttachment, AfnStrip, BugFilingData, CodeCoverage, IntermediateCollectorData, RunConfig, TestImpactDetails, TmiTestRunDeploymentFiles, TmiTestRunReverseDeploymentFiles, TmiTestResultDetail, TmiTestRunSummary }

comment

string

Comment associated with attachment

fileName

string

Attachment filename

stream

string

Base64 encoded file stream