YouTrack Standalone 2019.2 Help

Issue Attachments

This resource lets you work with attachments in the specific issue.

Resource

/api/issues/{issueID}/attachments

Returned entity

IssueAttachment. For the description of the entity attributes, see Supported Fields section.

Supported methods

IssueAttachment attributes

Represents a file that is attached to an issue or a comment.

This table describes attributes of the IssueAttachment entity.

  • To receive an attribute in the response from server, specify it explicitly in the request parameter fields.

  • To update an attribute, provide it in the body of a POST request.

Field

Type

Description

name

String

The name of the file. Can be null.

author

User

The user who attached the file to the issue. Read-only. Can be null.

created

Long

The date and time when the attachment was created as a timestamp. Read-only.

updated

Long

The date and time the attachment was last updated as a timestamp. Read-only.

size

Long

The size of the attached file in bytes. Read-only.

extension

String

The extension that defines the file type. Read-only. Can be null.

charset

String

Charset of the file. Read-only. Can be null.

mimeType

String

Mime type of the file. Read-only. Can be null.

metaData

String

The dimensions of an image file. For an image file, the value is rw=&rh=. For a non-image file, the value is empty. Read-only. Can be null.

draft

Boolean

If true, attachment is not yet published, otherwise false. Read-only.

removed

Boolean

If true, then attachment is considered to be removed. Read-only.

base64Content

String

The Data URI that represents the attachment with the following syntax:

data:[<media type>][;base64],<data>

For example:

"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="
Can be null.

url

String

URL of the file. Read-only. Can be null.

visibility

Visibility

Access setting of the attachment. Can be null.

issue

Issue

The issue that the file is attached to. Read-only. Can be null.

comment

IssueComment

The comment that the file is attached to. Returns null, if the file was attached directly to the issue. Read-only.

thumbnailURL

String

URL of the attachment thumbnail. Read-only. Can be null.

Read a List of IssueAttachments

Get a list of all attachments of the specific issue.

Request syntax

GET /api/issues/{issueID}/attachments?{fields}&{$top}&{$skip}

Request parameters

Parameter

Type

Description

fields

String

A list of IssueAttachment attributes that should be returned in the response. If no field is specified,only the entityID is returned

$skip

Int

Optional. Lets you set a number of returned entities to skip before returning the first one.

$top

Int

Optional. Lets you specify the maximum number of entries that are returned in the response.

Sample

Sample request URI

https://example.myjetbrains.com/youtrack/api/issues/2-6/attachments?fields=id,name,author(id,name),created,updated,size,mimeType,extension,charset,metaData,url

Sample response body

[ { "created": 1554209839634, "updated": 1554209839578, "author": { "name": "John Smith", "id": "1-1", "$type": "User" }, "metaData": "rw=568&rh=902", "charset": null, "name": "2019-03-28_14-30-46.png", "size": 208788, "extension": "png", "url": "/youtrack/_persistent/2019-03-28_14-30-46.png?file=7-2&c=false&updated=1554209839578", "mimeType": "image/png", "id": "7-2", "$type": "IssueAttachment" }, { "created": 1554209920779, "updated": 1554209920719, "author": { "name": "John Smith", "id": "1-1", "$type": "User" }, "metaData": "rw=375&rh=226", "charset": null, "name": "older-versions.png", "size": 23812, "extension": "png", "url": "/youtrack/_persistent/older-versions.png?file=7-3&c=false&updated=1554209920719", "mimeType": "image/png", "id": "7-3", "$type": "IssueAttachment" }, { "created": 1554223990031, "updated": 0, "author": { "name": "Jane Doe", "id": "1-3", "$type": "User" }, "metaData": "rw=375&rh=226", "charset": null, "name": "older-versions.png", "size": 23812, "extension": "png", "url": "/youtrack/_persistent/older-versions.png?file=7-6&c=false&updated=0", "mimeType": "image/png", "id": "7-6", "$type": "IssueAttachment" }, { "created": 1554223990031, "updated": 0, "author": { "name": "Jane Doe", "id": "1-3", "$type": "User" }, "metaData": "empty", "charset": null, "name": "readme-rest-docs.md", "size": 3503, "extension": "md", "url": "/youtrack/_persistent/readme-rest-docs.md?file=7-7&c=false&updated=0", "mimeType": "text/markdown", "id": "7-7", "$type": "IssueAttachment" } ]

Add a New IssueAttachment

Add an attachment to the issue.

Request syntax

POST /api/issues/{issueID}/attachments?{fields}

Request parameters

Parameter

Type

Description

fields

String

A list of IssueAttachment attributes that should be returned in the response. If no field is specified,only the entityID is returned

Sample

To create an attachment in an issue, you need to send a POST request to an endpoint like the one specified in this sample. As the format for request differs for various languages and tools, we do not provide specific example here. Instead, please a sample step-by-step procedure on the use case page.

Sample request URI

https://example.myjetbrains.com/youtrack/api/issues/2-6/attachments?fields=id,name,author(id,name),created,updated,size,mimeType,extension,charset,metaData,url
Last modified: 22 October 2019