There are two endpoints regarding attachments in Xray.


Get attachment

/api/v1/attachments/{attachmentId}

Add attachment

/api/v1/attachments


Get attachment

To download large attachment files, please use version 2 of the REST API.

To get attachments, you can use the following endpoint:


Get an attachment


Request

PARAMETERS

parameter

type

description

attachmentIdString

- id of the attachment to get.


Example:

curl -H "Content-Type: application/json" -X GET -H "Authorization: Bearer $token" https://xray.cloud.getxray.app/api/v1/attachments/7e0073ec-cc9a-44fa-a2da-9d8c163caeae

Responses

200 OK : octet/stream : Successful. The attachment is retrieved.

400 BAD_REQUEST : application/json : The attachment could not be retrieved.
Example Output

{
    "error": "No such file"
}



401 UNAUTHORIZED: application/json:
The API token is invalid.


Add attachment

 To add attachments, you can use the following endpoint:


Add attachment

Request

Example

curl -H "Content-Type: multipart/form-data" -X POST -F attachment=@report.pdf -H "Authorization: Bearer $token" https://xray.cloud.getxray.app/api/v1/attachments

Responses

200 OK : application/json : Successful. The attachment was added.

{
  "id": "7e0073ec-cc9a-44fa-a2da-9d8c163caeae",
  "filename": "report.pdf",
  "created": "2020-06-28T16:59:33.051Z",
  "size": 123446
}


400 BAD_REQUEST : application/json : The attachment information was not provided.

{
  "error": "No file found."
}


401 UNAUTHORIZED : application/json : The Xray license is not valid.