Files and Attachments APIs

Attachments provide more information about a contact or a company, which normally cannot be displayed. You may also need to send images, text files or videos or any other type of files to contacts. The files and attachments API allows a user to get a list of attachments, upload or download a photo or a file.

Get list of Attachments

Purpose

To get the list of attachments.

Request Details

Request URL

https://www.zohoapis.com/bigin/v1/{module_api_name}/{record_id}/Attachments

Supported module

Companies, Contacts, Deals, Tasks, Events, Calls and Products

Header

Authorization: Zoho-oauthtoken d92d4xxxxxxxxxxxxx15f52

Scope

scope=ZohoBigin.modules.ALL
(or)
scope=
ZohoBigin.modules.{module_name}.{operation_type}
(and)
scope=
ZohoBigin.modules.attachments.{operation_type}

Possible module names

accounts(companies in Bigin), contacts, deals, tasks, events, calls, products and notes

Possible operation types

ALL - Full access to attachments
READ - Get attachment data

Sample Request

Copiedcurl "https://www.zohoapis.com/bigin/v1/Contacts/1000000231009/Attachments"
-X GET
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
CopiedZBiginRecord record = ZBiginRecord.getInstance("Products",23857634545l);//module api name with record id
BulkAPIResponse response = record.getAllAttachmentsDetails();
List<ZBiginAttachment> list = ((List<ZBiginAttachment>) response.getData());
Copiedtry{
$record=ZBiginRecord::getInstance("Leads",410405000001111007);
$responseIns=$record->getAttachments(1,50);
$records=$responseIns->getData();
foreach ($records as $attchmentIns)
{
echo $attchmentIns->getId();
echo $attchmentIns->getFileName();
echo $attchmentIns->getFileType();
echo $attchmentIns->getSize();
echo $attchmentIns->getParentModule();
$parentRecord=$attchmentIns->getParentRecord();
echo $parentRecord->getEntityId();
echo $attchmentIns->getParentName();
echo $attchmentIns->getParentId();
$createdBy=$attchmentIns->getCreatedBy();
echo $createdBy->getId();
echo $createdBy->getName();
$modifiedBy=$attchmentIns->getModifiedBy();
echo $modifiedBy->getId();
echo $modifiedBy->getName();
$owner=$attchmentIns->getOwner();
echo $owner->getId();
echo $owner->getName();
echo $attchmentIns->getCreatedTime();
echo $attchmentIns->getModifiedTime();
}
}catch (ZBiginException $e)
{
echo $e->getMessage();
echo $e->getExceptionCode();
echo $e->getCode();
}
Copieddef get_attachments(self):
        try:
            record = ZBiginRecord.get_instance('Leads', 3719520000000326007)  # module API Name, entityId
            resp = record.get_attachments()
            print(resp.status_code)
            attachment_ins_arr = resp.data
            for attachment_ins in attachment_ins_arr:
                print(attachment_ins.id)
                print(attachment_ins.file_name)
                print(attachment_ins.file_type)
                print(attachment_ins.size)
                print(attachment_ins.owner.id)
                print(attachment_ins.created_by.id)
                print(attachment_ins.modified_by.id)
                print(attachment_ins.created_time)
                print(attachment_ins.modified_time)
                print(attachment_ins.parent_module)
                print(attachment_ins.attachment_type)
                print(attachment_ins.parent_name)
                print(attachment_ins.parent_id)
                print(attachment_ins.parent_record.entity_id)

        except ZBiginException as ex:
            print(ex.status_code)
            print(ex.error_message)
            print(ex.error_code)
            print(ex.error_details)
            print(ex.error_content)
CopiedZBiginRecord recordIns = ZBiginRecord.GetInstance("Leads", 3372164000000614001); //module api name with record id
BulkAPIResponse<ZBiginAttachment> response = recordIns.GetAttachments();
List<ZBiginAttachment> attachments = response.BulkData; //attachments - list of ZBiginAttachment instance
Copiedresponse = invokeurl
[
	url: "https://www.zohoapis.com/bigin/v1/Leads/1000000231009/Attachments"
	type: GET
	connection:"bigin_oauth_connection"
];
info response;

Response JSON Keys

  • OwnerJSON object

    Represents the name, ID, and email of the record owner.

  • Modified_Timestring

    Represents the date and time at which the attachment was last modified.

  • File_Namestring

    Represents the name of the attachment.

  • Created_Timestring

    Represents the date and time at which the attachment was added to the record.

  • Sizeinteger

    Represents the size of the attachment.

  • Parent_IdJSON object

    Represents the name and ID of the parent record.

  • $editableboolean

    Represents if the user can edit the attachment.
    true: The user can edit the attachment.
    false: The user cannot edit the attachment.

  • $file_idstring

    Represents the unique file ID of the file in the ZFS.

  • $se_modulestring

    Represents the API name of the parent module.

  • Modified_ByJSON object

    Represents the name, ID, and email of the user who last modified the attachment.

  • idstring

    Represents the unique ID of the related record.

  • Created_ByJSON object

    Represents the name, ID, and email of the user who added the attachment to the record.

Possible Errors

  • INVALID_MODULEHTTP 400

    The module name given seems to be invalid
    Resolution: You have specified an invalid module name or there is no tab permission, or the module could have been removed from the available modules. Specify a valid module API name.

  • INVALID_MODULEHTTP 400

    The given module is not supported in API
    Resolution: The modules such as Documents and Projects are not supported in the current API. (This error will not be shown, once these modules are been supported). Specify a valid module API name.

  • INVALID_URL_PATTERNHTTP 404

    Please check if the URL trying to access is a correct one
    Resolution: The request URL specified is incorrect. Specify a valid request URL. Refer to request URL section above.

  • OAUTH_SCOPE_MISMATCHHTTP 401

    Unauthorized
    Resolution: Client does not have ZohoBigin.modules.attachments.READ scope. Create a new client with valid scope. Refer to scope section above.

  • NO_PERMISSIONHTTP 403

    Permission denied to read attachment details
    Resolution: The user does not have permission to read attachment details. Contact your system administrator.

  • INTERNAL_ERRORHTTP 500

    Internal Server Error
    Resolution: Unexpected and unhandled exception in Server. Contact support team.

  • INVALID_REQUEST_METHODHTTP 400

    The http request method type is not a valid one
    Resolution: You have specified an invalid HTTP method to access the API URL. Specify a valid request method. Refer to endpoints section above.

  • AUTHORIZATION_FAILEDHTTP 400

    User does not have sufficient privilege to read attachments
    Resolution: The user does not have the permission to read attachment details. Contact your system administrator.

Sample Response

Copied{
    "data": [
        {
            "Owner": {
                "name": "Patricia Boyle",
                "id": "4150868000000225013",
                "email": "patricia.b@zylker.com"
            },
            "Modified_Time": "2020-07-24T18:12:43+05:30",
            "File_Name": "Screen Shot 2020-07-21 at 11.27.04 PM.png",
            "Created_Time": "2020-07-24T18:12:43+05:30",
            "Size": "362207",
            "Parent_Id": {
                "name": "related records",
                "id": "4150868000002728001"
            },
            "$editable": true,
            "$file_id": "iewimc754be98ef89473fbf474139d65f758a",
            "$type": "Attachment",
            "$se_module": "Contacts",
            "Modified_By": {
                "name": "Patricia Boyle",
                "id": "4150868000000225013",
                "email": "patricia@zylker.com"
            },
            "$state": "save",
            "id": "4150868000002728012",
            "Created_By": {
                "name": "Patricia Boyle",
                "id": "4150868000000225013",
                "email": "patricia@zylker.com"
            },
            "$link_url": null
        }
    ],
    "info": {
        "per_page": 200,
        "count": 1,
        "page": 1,
        "more_records": false
    }
}