Hello everyone!
Welcome back to another post in the Kaizen series.
We will also discuss how you can upload, download, and delete the photo of a record in a module.
What is an attachment?
An attachment could be a file (image, text file, video etc) or a link that you want to upload to a record. Attachments add more information to a record that can otherwise not be displayed.
1. Upload an attachment to a record
Request URL: {api-domain}/crm/v2/{module_api_name}/{record_id}/Attachments
Request method: POST
Scope: ZohoCRM.modules.ALL
(or)
ZohoCRM.modules.{module_name}.{operation_type}
(and)
ZohoCRM.modules.attachments.ALL/CREATE/WRITE
You must upload the attachment as form-data.
Here is a screenshot to upload a file as an attachment to a contact.
Here is a screenshot to upload a link as an attachment to a contact.
Sample Response
Note
- You cannot upload the organization's photo through this API. Use the Upload Org photo API, instead.
- You can also use this API to upload an attachment to a note. The request URL would be {api-domain}/crm/v2/Notes/{note_id}/Attachments.
- When you exceed the storage limit for the attachments for your edition, you can purchase additional storage. Click here to know more.
Possible Errors
| Reason
| Handling
|
| You are trying to add the existing URL as an attachment.
| All the attachment URLs must be unique.
|
| You are trying to attach a file and a URL in the same request.
| You can attach either a file or a URL at a time.
|
2. Get the list of attachments
Request URL: {api-domain}/crm/v2/{module_api_name}/{record_id}/Attachments
Request method: GET
Scope: ZohoCRM.modules.ALL
(or)
ZohoCRM.modules.{module_name}.{operation_type}
(and)
ZohoCRM.modules.attachments.ALL/READ
Sample Response
3. Download an attachment
Request URL: {api-domain}/crm/v2/{module_api_name}/{record_id}/Attachments/{attachment_id}
Request method: GET
Scope: ZohoCRM.modules.ALL
(or)
ZohoCRM.modules.{module_name}.{operation_type}
(and)
ZohoCRM.modules.attachments.ALL/READ
Note
You cannot download links but only files like image, PDF, text etc using this API.
Sample Response
4. Upload a photo to a record
A photo refers to the display picture of a record. Using this API, you can upload, download, and delete the display picture of the records in a module.
Leads, Contacts, Accounts, Products, Vendors, and custom modules are supported in this API.
Request URL: {api-domain}/crm/v2/{module_api_name}/{record_id}/photo
Request method: POST
Scope: ZohoCRM.modules.ALL
(or)
ZohoCRM.modules.{module_name}.ALL/CREATE/WRITE
You must send the image as form-data.
Note
The photo you want to upload must not exceed the allowed size(10 MB) or the allowed resolution(10 MP).
Here is an example.
5. Download the photo of a record
Request URL: {api-domain}/crm/v2/{module_api_name}/{record_id}/photo
Request method: GET
Scope: ZohoCRM.modules.ALL
(or)
ZohoCRM.modules.{module_name}.ALL/READ
Here is an example.
6. Delete the photo of a record
Request URL: {api-domain}/crm/v2/{module_api_name}/{record_id}/photo
Request method: DELETE
Scope: scope=ZohoCRM.modules.ALL
(or)
scope=ZohoCRM.modules.{module_name}.ALL/DELETE
Here is an example.
We hope you found this post useful. We will meet next week with another one.
Let us know your questions in the comments section, or write to us at support@zohocrm.com.
Cheers!