GET: Read an attachment
This topic provides instructions for using the GET operation to read an attachment.
Overview
An attachment instance has both entity and binary data. The properties of an attachment instance are represented by data in JSON format.
Attachment instances are members of attachment collections. See Attachments.
To get the attachment resource for an attachment entity, use the URI for the attachment collection with the attachment entity ID appended.
Tip: To get the entity ID, first read all instances and locate the desired entity.
Example: GET /shared_spaces/<space_id>/workspaces/<workspace_id>/attachments/50
, where 50 is the attachment ID.
The GET supports two content types:
-
application/json. To retrieve the attachment’s entity data only
-
application/octet-stream. To retrieve the attachment’s binary content only
Note: When getting instances, the REST API does not necessarily display all fields for the instance. For a complete list of available fields, see Retrieve metadata.
Examples
This GET request on attachments returns only the entity data of the attachment, without the binary content of the attachment.
GET .../api/shared_spaces/<space_id>/workspaces/<workspace_id>/attachments
{
"total_count": 2,
"data": [
{ "type": "attachment", "creation_time": "2016-10-27T12:20:59Z", "version_stamp": 1, "author": { "type": "workspace_user", "full_name": "MyAPIAccess", "name": "MyAPIAccess_rnj70jxlvk6d3sqn2n227y6xk", "id": "1003" }, "name": "Temp1.txt", "description": null, "id": "1002", "last_modified": "2016-10-27T12:20:59Z" }, { "type": "attachment", "creation_time": "2016-10-27T11:01:09Z", "version_stamp": 1, "author": { "type": "workspace_user", "full_name": "MyAPIAccess", "name": "MyAPIAccess_rnj70jxlvk6d3sqn2n227y6xk", "id": "1003" }, "name": "This page will soon be discontinued.docx", "description": null, "id": "1001", "last_modified": "2016-10-27T11:01:09Z" }
]
}
This GET request on attachments returns only the binary content of the attachment, without the data of the attachment. The content is a text file with the following content: “text file testing”
GET .../api/shared_spaces/<space_id>/workspaces/<workspace_id>/attachments/4003
*** Response ***
HTTP/1.1 200 OK
Content-Encoding: gzip
Content-Type: text/plain
Date: Mon, 27 Mar 2014 12:11:05 GMT
Server: MyServer
text file testing
See also: