Attachments

This chapter focuses on services for the attachments.

Get attachment

A GET to /attachments/{id} returns the attachment with the given id.

Path parameters

Table 1. /api/rest/latest/attachments/{id}
Parameter Description

id

the id of the attachment

HTTP request

GET /api/rest/latest/attachments/3 HTTP/1.1
Accept: application/json
Host: localhost:8080

Request parameters

Parameter Description

fields

which fields of the elements should be returned (optional)

HTTP response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 374

{
  "_type" : "attachment",
  "id" : 3,
  "name" : "sample attachment",
  "size" : 413168,
  "file_type" : "pdf",
  "added_on" : "2018-06-15T10:00:00.000+00:00",
  "_links" : {
    "self" : {
      "href" : "http://localhost:8080/api/rest/latest/attachments/3"
    },
    "content" : {
      "href" : "http://localhost:8080/api/rest/latest/attachments/3/content"
    }
  }
}

Response fields

Path Type Description

id

Number

the id of the attachment

_type

String

the type of the entity

name

String

the name of the attachment

file_type

String

the file type of the attachment

size

Number

the size of the attachment

added_on

String

the date this attachment was uploaded

_links

Object

related links

Relation Description

self

link to this attachment

content

link to download this attachment

Rename attachment

A PATCH to /attachments/{id} with new name in request parameters renames the attachment with the given id.

Path parameters

Table 1. /api/rest/latest/attachments/{id}
Parameter Description

id

the id of the attachment

HTTP request

PATCH /api/rest/latest/attachments/3 HTTP/1.1
Accept: application/json
Host: localhost:8080

Request parameters

Parameter Description

name

the new name for this attachment

fields

which fields of the elements should be returned (optional)

HTTP response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 383

{
  "_type" : "attachment",
  "id" : 3,
  "name" : "same stuff with a new name",
  "size" : 413168,
  "file_type" : "pdf",
  "added_on" : "2018-06-15T10:00:00.000+00:00",
  "_links" : {
    "self" : {
      "href" : "http://localhost:8080/api/rest/latest/attachments/3"
    },
    "content" : {
      "href" : "http://localhost:8080/api/rest/latest/attachments/3/content"
    }
  }
}

Response fields

Path Type Description

id

Number

the id of the attachment

_type

String

the type of the entity

name

String

the name of the attachment

file_type

String

the file type of the attachment

size

Number

the size of the attachment

added_on

String

the date this attachment was uploaded

_links

Object

related links

Relation Description

self

link to this attachment

content

link to download this attachment

Download attachment

A GET to /attachments/{id}/content downloads the attachment with the given id.

Path parameters

Table 1. /api/rest/latest/attachments/{id}/content
Parameter Description

id

the id of the attachment

HTTP request

GET /api/rest/latest/attachments/3/content HTTP/1.1
Content-Type: application/json
Accept: application/octet-stream
Host: localhost:8080

Upload attachment

A POST to /api/rest/latest/{owner}/{ownerId}/attachments/ uploads attachments in request body to the owner with the given id. The key of these attachments should always named as "files".

The possible {owners} are campaigns, campaign-folders, executions, execution-steps, iterations, projects, requirement-folders, requirement-versions, test-cases, test-case-folders, test-steps, test-suites

Path parameters

Table 1. /api/rest/latest/{owner}/{ownerId}/attachments
Parameter Description

owner

the owner of the attachment

ownerId

the id of the owner

HTTP request

POST /api/rest/latest/campaigns/1/attachments HTTP/1.1
Content-Type: multipart/form-data; boundary=6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm
Accept: application/json
Host: localhost:8080

--6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm
Content-Disposition: form-data; name=files; filename=new attachment 1.docx
Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document

something right
--6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm
Content-Disposition: form-data; name=files; filename=new attachment 2.pdf
Content-Type: application/pdf

even more
--6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm--

HTTP response

HTTP/1.1 201 Created
Content-Type: application/json
Content-Length: 541

{
  "_embedded" : {
    "attachments" : [ {
      "_type" : "attachment",
      "id" : 5,
      "name" : "new attachment 1",
      "file_type" : "docx",
      "_links" : {
        "self" : {
          "href" : "http://localhost:8080/api/rest/latest/attachments/5"
        }
      }
    }, {
      "_type" : "attachment",
      "id" : 6,
      "name" : "new attachment 2",
      "file_type" : "pdf",
      "_links" : {
        "self" : {
          "href" : "http://localhost:8080/api/rest/latest/attachments/6"
        }
      }
    } ]
  }
}

Response fields

Path Type Description

_embedded.attachments

Array

the attachments just uploaded

Delete attachment

A DELETE to /api/rest/latest/{owner}/{ownerId}/attachments/ with attachmentIds in request parameters removes these attachments from their owner with the given id.

The possible {owners} are campaigns, campaign-folders, executions, execution-steps, iterations, projects, requirement-folders, requirement-versions, test-cases, test-case-folders, test-steps, test-suites

Path parameters

Table 1. /api/rest/latest/{owner}/{ownerId}/attachments
Parameter Description

owner

the owner of the attachment

ownerId

the id of the owner

HTTP request

DELETE /api/rest/latest/campaigns/1/attachments?attachmentIds=7,8,9 HTTP/1.1
Content-Type: multipart/form-data
Accept: application/json
Host: localhost:8080

Request parameters

Parameter Description

attachmentIds

the ids of the attachments to delete