This method is used to add attachments on an existing entity. This Web API method requires a multipart/form-data post, as defined in RFC 1867. There are many libraries available that can be used in order to submit multipart/form-data posts (for example MultipartEntity in Java). A single attachment can be added through each call
Resource URL
Parameters
Name | Type | Description |
token | String | The token retrieved from the login method |
entity (mandatory) | String | The name of the entity related with the attachments that should be returned as a result. The supported entities are the following: - ACCOUNTSRECEIVABLE
- ACTIVITIES
- COMMUNICATIONS
- COMMUNICATIONTEMPLATES
- CONTACTINFORMATION
- INSTALLEDITEMS
- JOBS
- LEADS
- PRODUCTS
- SERVICEREQUESTS
- ATTACHMENTSLIBRARY
|
entity_id (mandatory on conditions) | String | The ID of the entity related with the attachments that should be returned as a result, and is mandatory only if the entity is not set to ATTACHMENTSLIBRARY |
attachment_id (semi-optional) | String | The ID of the attachment that should be added as an attachment on the entity Applicable only if - The entity is set to COMMUNICATIONS or COMMUNICATIONTEMPLATES
- The attachment already exists in the system's Attachments Library
|
file (semi-optional) | File | The file that should be added as an attachment |
url (semi-optional) | String | The URL that should be added as an attachment |
classification_identifier (mandatory on conditions) | Attachments Classification Identifier | The classification identifier of the attachment, which is mandatory only if the entity is set to ATTACHMENTSLIBRARY. The allowed classification identifier fields are the following:
Name | Type | Description |
---|
id (semi-optional) | String | The ID of the attachment classification | name (semi-optional) | String | The name of the attachment classification | alternative_code (semi-optional) | String | The alternative code of the attachment classification |
|
notes (optional) | String | The notes related with the attachment |
fields_set (optional) | List of Strings, comma separated | A list of fields that should be included in the results. If not specified then all the available fields will be returned |
Restrictions
- It is mandatory to specify one of the semi-optional parameters. Only one of those parameters is allowed to be specified.
Response Data
Name | Type | Description |
---|
id | String | The ID of the retrieved attachment |
entity | String | The name of the entity related with the attachment. The supported entities are the following: - ACCOUNTSRECEIVABLE
- ACTIVITIES
- COMMUNICATIONS
- COMMUNICATIONTEMPLATES
- CONTACTINFORMATION
- INSTALLEDITEMS
- JOBS
- LEADS
- PRODUCTS
- SERVICEREQUESTS
- ATTACHMENTSLIBRARY
|
entity_id | String | The ID of the entity related with the attachment. |
url | String | The attached URL. This information is empty if the attachment is a file. |
notes | String | The comments related with the retrieved attachment |
classification | Attachments Classification Object | The classification of the attachment |
file | File Object | The information of the attached file. This information is empty if the attachment is a URL. |
log_information | Log Information Object | The log information of the retrieved attachment |
Referred Objects Response Data
classification object response data
Name | Type | Description |
id | String | The id of the retrieved attachment classification |
name | String | The name of the retrieved attachment classification |
alternative_code | String | The alternative code of the retrieved attachment classification |
file object response data
Name | Type | Description |
---|
file_name | String | The name of the file |
file_content_url | String | The url that can be used to access the actual content of the file |
file_mime_type | String | The mime type of the attached file |
log_information object response data
Name | Type | Description |
created_date | Date | The date that the retrieved record was created |
updated_date | Date | The last date that the retrieved record was updated |
created_by_unit | Unit Object | The unit that created the retrieved record |
created_by_business_unit | Unit Object | The unit that created the retrieved record |
created_by_user | User Object | The user that created the retrieved record |
updated_by_unit | Unit Object | The last unit that updated the retrieved record |
updated_by_business_unit | Unit Object | The last unit that updated the retrieved record |
updated_by_user | User Object | The last user that updated the retrieved record |
Referred Objects Response Data
unit object response data
Name | Type | Description |
---|
id | String | The ID of the retrieved unit |
name | String | The name of the retrieved unit |
group_name | String | The name of the group that the retrieved unit belongs to |
community_name | String | The name of the community that the retrieved unit belongs to |
alternative_code | String | The alternative code of the retrieved unit |
description | String | The description of the retrieved unit |
business unit object response data
Name | Type | Description |
---|
id | String | The ID of the retrieved business unit |
name | String | The name of the retrieved business unit |
code | String | The code of the retrieved business unit |
unified_code | String | The unified code of the retrieved business unit |
description | String | The description of the retrieved business unit |
parent_business_unit_name | String | The name of the parent business unit that the retrieved business unit belongs to |
user object response data
Name | Type | Description |
---|
id | String | The ID of the retrieved user |
username | String | The user name of the retrieved user |
person_name | String | The full name of the retrieved user |
email | String | The email of the retrieved user |
Examples
Example 1
cURL Example:
curl --request POST \
--url {{server}}/crmapi/rest/v2/attachments/add \
--header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \
--form entity=CONTACTINFORMATION \
--form 'token={{token}}' \
--form entity_id=18686813304341ECAFC8175A85594C9B \
--form 'notes=My Web API notes' \
--form url=www.crm.com \
--form 'file=@[object Object]'
PHP Example:
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "{{server}}/crmapi/rest/v2/attachments/list?token={{token}}&entity=CONTACTINFORMATION&entity_id=18686813304341ECAFC8175A85594C9B",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}