相关列表API
记录通常包含额外的信息,如备注、附件、产品、商机、联系人等。使用相关列表API,您可以检索所有相关列表信息。
获取相关记录
目的
用来获取相关列表记录。
请求URL
https://www.zohoapis.com.cn/crm/v2/{module_api_name}/{record_id}/{related_list_api_name}
module_api_name - 模块的API名称
record_id - 记录的唯一ID
related_list_api_name - 相关列表的API名称。要获取相关列表的API名称,请查看相关列表元数据
支持的关系 |
---|
市场活动 - 到 - 线索,联系人 产品 - 到 - 线索,客户, 联系人,商机,价格表 |
请求方法
GET
范围
scope=ZohoCRM.modules.all
(或)
scope=ZohoCRM.modules.{module_name}.{operation_type}
可能的模块名称 | 可能的操作类型 |
---|---|
线索,商机,联系人,客户,产品,市场活动和价格表 | ALL - 完全访问相关记录 WRITE - 编辑相关记录 DELETE - 删除相关记录 |
备注:
page 和 per_page参数用于根据记录在CRM中的位置获取记录。假设用户必须获取400条记录。一个API调用最多可以获得200条记录。因此,对于第200条以上的记录,无法获取。通过使用page(1,2,3,4)和per_page(100)参数,用户可以使用4个API调用获取所有400条记录。
请求报头
Header name | 数据类型 | 描述 | 示例 |
---|---|---|---|
If-Modified-Since (可选) | DateTime(ISO 8601 格式) | 获取最近修改的记录列表 | 2019-07-25T15:26:49+05:30 |
可能的错误
HTTP状态 | 错误码 | 消息 | 原因 |
---|---|---|---|
400 | INVALID_DATA | 给出的关系名称似乎无效 | 如果RelatedModule或RelatedAPIName无效 |
示例请求
curl "https://www.zohoapis.com.cn/crm/v2/Leads/410888000000698006/Notes"
-X GET
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
示例响应
{
"data": [
{
"Owner": {
"name": "Patricia Boyle",
"id": "2883756000000133013"
},
"$se_module": "Leads",
"$approval": {
"delegate": false,
"approve": false,
"reject": false
},
"Modified_By": {
"name": "Patricia Boyle",
"id": "2883756000000133013"
},
"Modified_Time": "2016-09-15T18:03:09+05:30",
"Created_Time": "2016-09-15T18:03:09+05:30",
"$followed": false,
"Parent_Id": {
"name": "Deborah Grogan",
"id": "2883756000000135187"
},
"id": "410888000000734003",
"Created_By": {
"name": "Patricia Boyle",
"id": "410888000000086001"
},
"Note_Title": "",
"Note_Content": "Demo scheduled for this Lead"
}
],
"info": {
"per_page": 200,
"count": 1,
"page": 1,
"more_records": false
}
}
示例请求
ZCRMRecord record = ZCRMRecord.getInstance("Contacts", 12345l);//模块API名称和记录ID
BulkAPIResponse response = record.getRelatedListRecords("Deals");
List<ZCRMRecord> deals = (List<ZCRMRecord>) response.getData(); //相关列表名称
示例响应
{
"data": [
{
"Owner": {
"name": "Patricia Boyle",
"id": "2883756000000133013"
},
"$se_module": "Leads",
"$approval": {
"delegate": false,
"approve": false,
"reject": false
},
"Modified_By": {
"name": "Patricia Boyle",
"id": "2883756000000133013"
},
"Modified_Time": "2016-09-15T18:03:09+05:30",
"Created_Time": "2016-09-15T18:03:09+05:30",
"$followed": false,
"Parent_Id": {
"name": "Deborah Grogan",
"id": "2883756000000135187"
},
"id": "410888000000734003",
"Created_By": {
"name": "Patricia Boyle",
"id": "410888000000086001"
},
"Note_Title": "",
"Note_Content": "Demo scheduled for this Lead"
}
],
"info": {
"per_page": 200,
"count": 1,
"page": 1,
"more_records": false
}
}
示例请求
$zcrmRecordIns = ZCRMRecord::getInstance(“Products", 410405000001108011);
$bulkAPIResponse=$zcrmRecordIns->getRelatedListRecords(“Deals”);
$relatedRecordsList=$bulkAPIResponse->getData(); // $relatedRecordsList - 与给定产品相关的ZCRMRecord实例的数组。
示例响应
{
"data": [
{
"Owner": {
"name": "Patricia Boyle",
"id": "2883756000000133013"
},
"$se_module": "Leads",
"$approval": {
"delegate": false,
"approve": false,
"reject": false
},
"Modified_By": {
"name": "Patricia Boyle",
"id": "2883756000000133013"
},
"Modified_Time": "2016-09-15T18:03:09+05:30",
"Created_Time": "2016-09-15T18:03:09+05:30",
"$followed": false,
"Parent_Id": {
"name": "Deborah Grogan",
"id": "2883756000000135187"
},
"id": "410888000000734003",
"Created_By": {
"name": "Patricia Boyle",
"id": "410888000000086001"
},
"Note_Title": "",
"Note_Content": "Demo scheduled for this Lead"
}
],
"info": {
"per_page": 200,
"count": 1,
"page": 1,
"more_records": false
}
}
示例请求
def get_related_records(self):
try:
record=ZCRMRecord.get_instance('Leads',440872000000222019) #module API Name, entityId
resp=record.get_relatedlist_records('Products') #related list API Name
print resp.status_code
record_ins_arr=resp.data
for record_ins in record_ins_arr:
print record_ins.entity_id
print record_ins.owner.id
print record_ins.created_by.id
print record_ins.modified_by.id
print record_ins.created_time
print record_ins.modified_time
print record_ins.get_field_value('Product_Name')
print record_ins.get_field_value('Product_Code')
print record_ins.get_field_value('Vendor_Name')
print record_ins.get_field_value('Commission_Rate')
print record_ins.get_field_value('Qty_in_Demand')
print record_ins.get_field_value('Tax')
print record_ins.get_field_value('Unit_Price')
print record_ins.get_field_value('Reorder_Level')
print record_ins.get_field_value('Usage_Unit')
print record_ins.get_field_value('Qty_Ordered')
print record_ins.get_field_value('Qty_in_Stock')
print record_ins.get_field_value('Sales_Start_Date')
print record_ins.get_field_value('Sales_End_Date')
print record_ins.get_field_value('Taxable')
print record_ins.get_field_value('Support_Expiry_Date')
print record_ins.get_field_value('Manufacturer')
print record_ins.get_field_value('Description')
print record_ins.field_data
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": [
{
"Owner": {
"name": "Patricia Boyle",
"id": "2883756000000133013"
},
"$se_module": "Leads",
"$approval": {
"delegate": false,
"approve": false,
"reject": false
},
"Modified_By": {
"name": "Patricia Boyle",
"id": "2883756000000133013"
},
"Modified_Time": "2016-09-15T18:03:09+05:30",
"Created_Time": "2016-09-15T18:03:09+05:30",
"$followed": false,
"Parent_Id": {
"name": "Deborah Grogan",
"id": "2883756000000135187"
},
"id": "410888000000734003",
"Created_By": {
"name": "Patricia Boyle",
"id": "410888000000086001"
},
"Note_Title": "",
"Note_Content": "Demo scheduled for this Lead"
}
],
"info": {
"per_page": 200,
"count": 1,
"page": 1,
"more_records": false
}
}
示例请求
语法:
zoho.crm.getRelatedRecords(<module String>,<parentModuleName String>,<recordId Long>,<page Long>,<perPage Long>,<connectionName String>,<userAccess Boolean>);
mandatory : module,parentModuleName,recordId
示例请求:
resp = zoho.crm.getRelatedRecords("Related_List_Name_2","Leads","7000000037002");
示例响应
{
"data": [
{
"Owner": {
"name": "Patricia Boyle",
"id": "2883756000000133013"
},
"$se_module": "Leads",
"$approval": {
"delegate": false,
"approve": false,
"reject": false
},
"Modified_By": {
"name": "Patricia Boyle",
"id": "2883756000000133013"
},
"Modified_Time": "2016-09-15T18:03:09+05:30",
"Created_Time": "2016-09-15T18:03:09+05:30",
"$followed": false,
"Parent_Id": {
"name": "Deborah Grogan",
"id": "2883756000000135187"
},
"id": "410888000000734003",
"Created_By": {
"name": "Patricia Boyle",
"id": "410888000000086001"
},
"Note_Title": "",
"Note_Content": "Demo scheduled for this Lead"
}
],
"info": {
"per_page": 200,
"count": 1,
"page": 1,
"more_records": false
}
}
示例请求
ZCRMRecord recordIns= ZCRMRecord.GetInstance("Leads", 3372164000000); //模块API名称和记录ID
BulkAPIResponse<ZCRMRecord> response = recordIns.GetRelatedListRecords("Products"); //相关列表API名称
List<ZCRMRecord> relatedRecordsLists = response.BulkData; //relatedRecordsLists - ZCRMRecord实例列表
示例响应
{
"data": [
{
"Owner": {
"name": "Patricia Boyle",
"id": "2883756000000133013"
},
"$se_module": "Leads",
"$approval": {
"delegate": false,
"approve": false,
"reject": false
},
"Modified_By": {
"name": "Patricia Boyle",
"id": "2883756000000133013"
},
"Modified_Time": "2016-09-15T18:03:09+05:30",
"Created_Time": "2016-09-15T18:03:09+05:30",
"$followed": false,
"Parent_Id": {
"name": "Deborah Grogan",
"id": "2883756000000135187"
},
"id": "410888000000734003",
"Created_By": {
"name": "Patricia Boyle",
"id": "410888000000086001"
},
"Note_Title": "",
"Note_Content": "Demo scheduled for this Lead"
}
],
"info": {
"per_page": 200,
"count": 1,
"page": 1,
"more_records": false
}
}