Upload Attachments
You can upload attachments to business objects.
The details of the Method, Request Body, and Headers to execute the Upload Attachment API are as given in the table below:
Base URL |
https://{tenant url}/api/rest/Attachment |
||||||||||||||
Method |
POST |
||||||||||||||
Header Name | Authorization: JTW Token/Session Key/REST API Key | ||||||||||||||
Request Body |
form-data
|
Here is an example to upload an attachment to an incident business object.
URL |
https://{tenant url}/api/rest/Attachment |
|||||||||||||||||
Method |
POST |
|||||||||||||||||
Header Name | Authorization: JTW Token/Session Key/REST API Key | |||||||||||||||||
Request Body |
form-data
|
|||||||||||||||||
Status Code |
200 |
|||||||||||||||||
Response Header |
[ { "FileName": "Invoice.png", "IsUploaded": true, "Message": "1968C01EFAB244AD8C67648E7578A30E" }, { "FileName": "BillOfMaterial.png", "IsUploaded": true, "Message": "1968C01EFAB244AD8C67648E7578A30E" } ] |
When attachment is successful, the Unique ID of the attachment is displayed in the Response Header Message.
Unsuccessful Responses
Scenario: Uploading two files to a business object where one of the file already exists in the business object.
Example:
https://{tenant url}/api/rest/Attachment
Header Name:
Authorization: Sessionkey
Code | ISM_3000 |
Description | Validation Error |
Message |
[ { "FileName": "CIMapButton.png", "IsUploaded": true, "Message": "FE36F27EBCF64A7BB88D9425E9738C08" }, { "FileName": "ChooseFilesButton.png", "IsUploaded": false, "Message": "Upload Failed, A file with the name 'ChooseFilesButton.png' is already attached to this object. Please change the name." } ] |
HTTP STATUS CODE |
300 |
The code 300 indicates, multiple responses, some success and some unsuccessful. The message contains the details of the success and unsuccessful responses.
Scenario: Trying to attach an unsupported file type.
Example:
https://{tenant url}/api/rest/Attachment
Header Name:
Authorization: Sessionkey
Code | ISM_3000 |
Description | Validation Error |
Message |
[ "Upload failed. Invalid attachment type. Attach a valid file type and try again". ] |
HTTP STATUS CODE |
300 |