Add attachment
OVERVIEW
API method to add an attachment to a content in Collaborate.
Request URI
POST /api/4/attachments?siteid={siteid}
Request body
The Media type should be set to multipart/form-data
Form Parameters
Parameter Name | Value | Description |
---|---|---|
filename | String | Name of the newly created file |
file | Binary file data | The parameter name should be called file and the value for it is the file to be uploaded |
siteid | int | Site ID. |
The file should be added as multipart form data. Please note that the parameters are case sensitive.
Response
If the operation is successful the API returns a progressive key resource object. And based on this progressive key, can see the status of attachment otherwise an error object is returned with the appropriate error code
To get the status of attachment based on progressive key
POST /api/{version}/progressivekeystatus/{progressive_key}
Name | Type | Description |
---|---|---|
progressive_key | String | Key to check the status of your action. |
Response
<attachment>
<id>101</id>
</attachment>
If the operation is successful the API returns a progressive key resource object. Possible statuses are "in-progress", "done" or "failed" otherwise, an error object is returned with the appropriate error code
Note: This API will insert an attachment/file into the system with a non-active state. The attachment ID you can use while adding/editing the content API such as task, blog, or event.
Thanks Andrew, thats exactly what I was looking for :)
Peter Harris, for iSheet's this was the old documentation for adding attachments to an iSheet (attachment) column.
It's essentially a three step process (swagger links provided):
For step 1, remember that for the multi-part form (POST) the filename field should not contain the file extension, e.g.
Where header (for example):
content-type: multipart/form-data; boundary=----WebKitFormBoundaryItF96ABacPkb9Bmc
Then payload:
Community Example Report
------WebKitFormBoundaryItF96ABacPkb9Bmc
Content-Disposition: form-data; name="file"; filename="Community Example Report.pdf"
Content-Type: application/pdf
............
............
FILE CONTENT
............
............
------WebKitFormBoundaryItF96ABacPkb9Bmc--
You'll receive the progress key to use for step 2 in the response from this endpoint, e.g.
{"progressivekey":"YZZLWt6MNN_1669642561894","progressivekeystatus":"INPROGRESS"}
Poll step 2 until you receive either a DONE, or a FAILED status. If done, then you'll receive the attachment id we need to set the column value for on the required isheet item, e.g.
{
"progressivekeystatus":"DONE",
"attachment":{
"id":3333
}
}
You then use this for the last step. So given an iSheet (999), an iSheet item (111111), and an attachment column (9991), then an example payload for the update iSheet item would look like:
{
"data": {
"item": [
{
"itemsequence": 1,
"alerteroption": 1,
"column": [
{
"attributecolumnid": 9990,
"rawdata": {
"value": "Updated record with report on 28th Nov 2022"
}
},
{
"attributecolumnid": 9991,
"rawdata": {
"attachments": {
"attachment": [
{ "id": 3333 }
]
}
}
}
]
}
]
}
}
How can I upload an attachment file to an existing Item row and column in an isheet?
I have not found a way to activate an attachment uploaded through the API (the above only states "This API will insert an attachment/file into the system with a non-active state. The attachment ID you can use while adding/editing the content API such as task, blog, or event." without elaborating further). Looking purely at the numeric value, the API call seems to return rather a file ID than an attachment ID, but the uploaded attachment / file is not accessible anywhere, neither through the task / blog API nor through the regular user interface. Did anybody have more luck with this, activating and actually using an attachment uploaded through the API? Any guidance would be much appreciated.
Comments
4 Comments