POST: Create an attachment

To create an attachment instance, perform a POST on the attachment collection, passing a JSON string.

Note: Bulk POSTs are not supported.

Attachments contain two different types of data that can be POSTed: 

The REST API supports content types of multipart/form-data.

Example: POST request for attachments

*** Request ***
POST .../api/shared_spaces/<shared_space_id>/workspaces/1003/attachments
Content-Type: multipart/form-data; boundary=a1b2c3d4
Accept: application/json

--a1b2c3d4
Content-Disposition: form-data; name="entity"
Content-Type: application/json; charset=UTF-8

{
                "owner_work_item": {
                                "id": 1002,
                                "type": "work_item"
                },
                "name": "attachment.png",
                "description": "This is attachment.png image file"
}
--a1b2c3d4
Content-Disposition: form-data; name="content"; filename="attachment.png"
Content-Type: image/png
Content-Transfer-Encoding: base64

iVBORw0KGgoAAAANSUhEUgAAALAAAAAzCAIAAAC48RV/AAAAAXNSR0IArs4c6QAAAARnQU1BAACx
jwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAALRSURBVHhe7ZjhUewwDITph3roh3qoh36OOLYc
rSRHd445YNjv17Msr2R5J9y8lxshChqCADQEAWgIAtAQBKAhCEBDEICGIAANQQAaggA0BAFoCALQ
EASgIQhAQxCAhiDAXzTE5/vrS+H1/bNFyDJoCAJ8gyE+3oLnCoOT/FZDrLzjj0FDrOM/G0LepNFn
0GaiefsIgzV/pCPAvuwqQ6h9fbZWLBFVuyX4iAJblS4LrVKsObh43UKUTtx8Uqiijh6YnDkmDBE2
07oJ5zIY1plOIdivm/HBjf4EQcUB6tXCQ72dpOjgjp6hjlTKbzfKOEZ3gVlDHLeVUfR2WgDbC4KJ
TqRb/60GUo/3gKjJWZewkRzp5SSjJeRFRULf0eN0jmaN7qgQlpHd3sVFFvyGsHMI53LHsDClraKL
ygyUmJF31fwREwn6w1HnRSMNT6CDoaxQ2+/bdn2RSUO0FjW9o3Aug2ENdYKxdLKRRdVcBEVkFYEZ
J5q+akCg04vv1ksL4UrSf/AL0ftH+gXCuQTBU51gLJ10ZEE1F0GRQS87T/tC3GmIsNlVfpgwROvu
aOGuufjguQ4OCclHNqx2RIyIP2HIi+YahbFOC6WFJL1zXvBBLhtC+j/aMgkVH0x0vG6J7MnpyOxy
w0WMiC+3sQdNfyea5kY77lgvJHm2claoLXSRlUz8yZB7G44LYELr3AcznWh/F8vfxiw3XOTspYDW
f17Udrwf7KEmMyzjEkaFYgE5fZm5H5X65vL/DOoCej8clwQzHby87ORvY5YbLhKI+GGrMedFCy1U
qGF3TAVU8iOFbJOCOnCBOUOQaYL3fgg5rywkxlrylaAhnsxVQ/jPUv9i0BB/kVVfCMeavxg0xLO5
aoiC+vFRWfJtqNAQBKAhCEBDEICGIAANQQAaggA0BAFoCALQEASgIQhAQxCAhiAADUEAGoIANAQB
aAgC0BBEcbt9ATZhuQV8mjteAAAAAElFTkSuQmCC
--a1b2c3d4--
*** Response ***
{
                "total_count": 1,
                "data": [{
                                "type": "attachment",
                                "creation_time": "2016-11-02T07:39:12Z",
                                "version_stamp": 1,
                                "author": {
                                                "type": "workspace_user",
                                                "id": "1001"
                                },
                                "name": "attachment.png",
                                "description": "This is attachment.png image file",
                                "id": "1001",
                                "last_modified": "2016-11-02T07:39:12Z"
                }],
                "exceeds_total_count": false
}

Back to top

See also: