文件和附件API

附件提供了关于联系人或公司的更多信息,这些信息通常无法显示。您可能还需要发送图片、文本文件或视频或任何其他类型的文件到联系人。文件和附件API允许用户获取附件列表、上传或下载照片或文件。

获取附件列表

目的

用来获取附件的列表。

请求URL

https://www.zohoapis.com.cn/crm/v2/{module_api_name}/{record_id}/Attachments

module_api_name - 模块的API名称

record_id - 记录的唯一ID

支持的模块
线索,客户,联系人,商机,市场活动,任务,服务支持,事件,通话,解决方案,产品,供货商,价格表,报价单,销售订单,采购订单,发货单,自定义模块和备注

请求方法

GET

范围

sscope=ZohoCRM.modules.all
(或)
scope=ZohoCRM.modules.{module_name}.{operation_type}
(和)scope=ZohoCRM.modules.attachments.all


可能的模块名称可能的操作类型
线索,客户,联系人,商机,市场活动,任务,服务支持,事件,通话,解决方案,产品,供货商,价格表,报价单,销售订单,采购订单,发货单,自定义模块,备注ALL - 完全访问附件
READ - 获取附件数据

示例请求


				curl "https://www.zohoapis.com.cn/crm/v2/Leads/1000000231009/Attachments"
-X GET
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"			

示例响应


				{
    "data": [
       {
            "id": "1000000030750",
            "Modified_By": "1000000028468",
            "Owner": "1000000028468",
            "Parent_Id": "1000000231009",
            "Created_Time": "2016-03-30 20:29:35",
            "Modified_Time": "2016-03-30 20:29:35",
            "$Created_By": "Patricia Boyle",
            "$Owner": "Patricia Boyle",
            "Created_By": "1000000028468",
            "File_Name": "External-Api-Automation.html",
            "$Modified_By": "Patricia Boyle",
            "Size": "985160"
        }
    ],
    "info": {
        "range": "1-1",
        "more_records": false
    }
}			

示例请求


				ZCRMRecord record = ZCRMRecord.getInstance("Products",23857634545l);//模块API名称和记录ID
BulkAPIResponse response = record.getAllAttachmentsDetails();
List<ZCRMAttachment> list = ((List<ZCRMAttachment>) response.getData());			

示例响应


				{
    "data": [
       {
            "id": "1000000030750",
            "Modified_By": "1000000028468",
            "Owner": "1000000028468",
            "Parent_Id": "1000000231009",
            "Created_Time": "2016-03-30 20:29:35",
            "Modified_Time": "2016-03-30 20:29:35",
            "$Created_By": "Patricia Boyle",
            "$Owner": "Patricia Boyle",
            "Created_By": "1000000028468",
            "File_Name": "External-Api-Automation.html",
            "$Modified_By": "Patricia Boyle",
            "Size": "985160"
        }
    ],
    "info": {
        "range": "1-1",
        "more_records": false
    }
}			

示例请求


				try{
$record=ZCRMRecord::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 (ZCRMException $e)
{
echo $e->getMessage();
echo $e->getExceptionCode();
echo $e->getCode();
}			

示例响应


				{
    "data": [
       {
            "id": "1000000030750",
            "Modified_By": "1000000028468",
            "Owner": "1000000028468",
            "Parent_Id": "1000000231009",
            "Created_Time": "2016-03-30 20:29:35",
            "Modified_Time": "2016-03-30 20:29:35",
            "$Created_By": "Patricia Boyle",
            "$Owner": "Patricia Boyle",
            "Created_By": "1000000028468",
            "File_Name": "External-Api-Automation.html",
            "$Modified_By": "Patricia Boyle",
            "Size": "985160"
        }
    ],
    "info": {
        "range": "1-1",
        "more_records": false
    }
}			

示例请求


				def get_attachments(self):
    try:
        record=ZCRMRecord.get_instance('Leads',440872000000222019) #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
            print "\n\n"
    except ZCRMException as ex:
        print ex.status_code
        print ex.error_message
        print ex.error_code
        print ex.error_details
        print ex.error_content			

示例响应


				{
    "data": [
       {
            "id": "1000000030750",
            "Modified_By": "1000000028468",
            "Owner": "1000000028468",
            "Parent_Id": "1000000231009",
            "Created_Time": "2016-03-30 20:29:35",
            "Modified_Time": "2016-03-30 20:29:35",
            "$Created_By": "Patricia Boyle",
            "$Owner": "Patricia Boyle",
            "Created_By": "1000000028468",
            "File_Name": "External-Api-Automation.html",
            "$Modified_By": "Patricia Boyle",
            "Size": "985160"
        }
    ],
    "info": {
        "range": "1-1",
        "more_records": false
    }
}			

示例请求


				ZCRMRecord recordIns = ZCRMRecord.GetInstance("Leads", 3372164000000614001); //模块API名称和记录ID
BulkAPIResponse<ZCRMAttachment> response = recordIns.GetAttachments();
List<ZCRMAttachment> attachments = response.BulkData; //attachments - ZCRMAttachment实例的列表		

示例响应


				{
    "data": [
       {
            "id": "1000000030750",
            "Modified_By": "1000000028468",
            "Owner": "1000000028468",
            "Parent_Id": "1000000231009",
            "Created_Time": "2016-03-30 20:29:35",
            "Modified_Time": "2016-03-30 20:29:35",
            "$Created_By": "Patricia Boyle",
            "$Owner": "Patricia Boyle",
            "Created_By": "1000000028468",
            "File_Name": "External-Api-Automation.html",
            "$Modified_By": "Patricia Boyle",
            "Size": "985160"
        }
    ],
    "info": {
        "range": "1-1",
        "more_records": false
    }
}