上传附件

目的

将文件附加到记录上。您必须将附件包含在内容类型为multipart/form data的请求中。

请求URL

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

module_api_name - 模块的API名称

record_id - 记录的唯一ID

在获取附件列表中支持的模块在这里也支持。

请求方法

POST

范围

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

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

参数

参数名称数据类型描述
file (必填)Text选择要上传的附件。

示例请求:将“文本”文件作为附件上传


				curl "https://www.zohoapis.com.cn/crm/v2/Leads/1000000231009/Attachments"
-X POST
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
-F "file=@attachment1.txt"			

示例请求:将“链接”作为附件上传


				curl "https://www.zohoapis.com.cn/crm/v2/Leads/1386586000003152001/Attachments"
-X POST
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
-F "attachmentUrl=https://www.zohocorp.com"			

示例响应


				{
    "data": [
       {
            "code": "SUCCESS",
            "details": {
                "id": "1000000231009"
            },
            "message": "attachment uploaded successfully",
            "status": "success"
        }
    ]
}			

示例请求


				ZCRMRecord record = ZCRMRecord.getInstance("Products",23857634545l);//模块API名称和记录ID
APIResponse response = record.uploadAttachment("FilePath");
ZCRMAttachment uploadAttachment = (ZCRMAttachment) response.getData();
String requestStatus =response.getStatus();			

示例响应


				{
    "data": [
       {
            "code": "SUCCESS",
            "details": {
                "id": "1000000231009"
            },
            "message": "attachment uploaded successfully",
            "status": "success"
        }
    ]
}			

示例请求


				try{
$record=ZCRMRecord::getInstance(“Leads”,”410405000001111007”);
$responseIns=$record->uploadAttachment($filePath); // $filePath - 要上传附件的绝对路径。
echo "HTTP Status Code:".$responseIns->getHttpStatusCode();
echo "Status:".$responseIns->getStatus();
echo "Message:".$responseIns->getMessage();
echo "Code:".$responseIns->getCode();
echo "Details:".$responseIns->getDetails()['id'];
}catch(ZCRMException $e)
{
echo $e->getCode();
echo $e->getMessage();
echo $e->getExceptionCode();
}			

示例响应


				{
    "data": [
       {
            "code": "SUCCESS",
            "details": {
                "id": "1000000231009"
            },
            "message": "attachment uploaded successfully",
            "status": "success"
        }
    ]
}			

示例请求


				def upload_attachment(self):
    try:
        record=ZCRMRecord.get_instance('Leads',1386586000001856002)
        resp=record.upload_attachment('/Users/Downloads/sequel-pro-1.1.dmg')
        print resp.data.id
nbsp;    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": [
       {
            "code": "SUCCESS",
            "details": {
                "id": "1000000231009"
            },
            "message": "attachment uploaded successfully",
            "status": "success"
        }
    ]
}			

示例请求


				ZCRMRecord recordIns = ZCRMRecord.GetInstance("Leads", 3372164000000614001);//模块API名称和记录ID
APIResponse response = recordIns.UploadAttachment("/Users/Bob/Desktop/testreport/report-dec-18.htm");
ZCRMAttachment uploadAttachment = (ZCRMAttachment)response.Data;			

示例响应


				{
    "data": [
       {
            "code": "SUCCESS",
            "details": {
                "id": "1000000231009"
            },
            "message": "attachment uploaded successfully",
            "status": "success"
        }
    ]
}