获取已删除记录的列表
目的
用来获取已删除记录的列表。
请求URL
https://www.zohoapis.com.cn/crm/v2/{module_api_name}/deleted
module_api_name - 模块的API名称
在获取记录列表中支持的模块在这里也支持。
请求方法
GET
范围
scope=ZohoCRM.modules.all
(或)
scope=ZohoCRM.modules.{module_name}.{operation_type}
可能的模块名称 | 可能的操作类型 |
---|---|
线索,客户,联系人,商机,市场活动,任务,服务支持,事件,通话,解决方案,产品,供货商,价格表,报价单,销售订单,采购订单,发货单,自定义模块和备注 | ALL - 完全访问记录 READ - 获取模块中的记录 |
请求报头
报头名称 | 数据类型 | 描述 | 示例 |
---|---|---|---|
If-Modified-Since(可选) | DateTime(ISO 8601 格式) | 获取最近修改的记录列表 | M2019-07-25T15:26:49+05:30 |
参数
参数名称 | 数据类型 | 描述 |
---|---|---|
module(必填) | 字符串 | 指定模块API名称 |
type | 字符串 | All 获取所有已删除记录的列表 Recycle 从回收站获取已删除记录的列表 Permanent 获取永久删除记录的列表 |
page(可选) | 整型 | To get the list of records from the respective pages. Default value for page is 1. |
per_page(可选) | 整型 | To get the list of records available per page. Default value for per page is 200. |
备注:
The page and per_page parameter is used to fetch records according to their position in the CRM. Let's assume that the user has to fetch 400 records. The maximum number of records that one can get for an API call is 200. So, for records above the 200th position, they cannot be fetched. By using the page (1, 2, 3 and 4) and per_page (100) parameter, the user can fetch all 400 records using 4 API calls.
可能的错误
HTTP状态 | 错误码 | 消息 | 原因 |
---|---|---|---|
400 | INVALID_DATA | Invalid data | Invalid type param value given. |
示例请求
curl "https://www.zohoapis.com.cn/crm/v2/Leads/deleted?type=All"
-X GET
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
示例响应
{
"data": [
{
"deleted_by": {
"name": "Patricia Boyle",
"id": "410888000000086001"
},
"id": "410888000000099071",
"display_name": "Patricia",
"type": "recycle",
"created_by": {
"name": "Patricia Boyle",
"id": "410888000000086001"
},
"deleted_time": "2015-06-19T11:19:38+05:30"
},
{
"deleted_by": {
"name": "Patricia Boyle",
"id": "410888000000086001"
},
"id": "410888000000094004",
"display_name": "Patricia",
"type": "recycle",
"created_by": {
"name": "Patricia Boyle",
"id": "410888000000086001"
},
"deleted_time": "2015-04-07T17:43:33+05:30"
},
{
"deleted_by": null,
"id": "410888000000680013",
"display_name": null,
"type": "permanent",
"created_by": null,
"deleted_time": "2016-10-26T11:44:15+05:30"
},
{
"deleted_by": null,
"id": "410888000000680009",
"display_name": null,
"type": "permanent",
"created_by": null,
"deleted_time": "2016-10-26T11:44:15+05:30"
}
],
"info": {
"per_page": 200,
"count": 4,
"page": 1,
"more_records": false
}
}
示例请求
ZCRMModule module = ZCRMModule.getInstance("Leads"); //模块API名称
BulkAPIResponse response = module.getAllDeletedRecords();
List<ZCRMRecord> deletedRecords = (List<ZCRMRecord>) response.getData();
List<ZCRMTrashRecord> recycleBinRecords = (List<ZCRMTrashRecord>) module.getRecycleBinRecords().getData();
List<ZCRMTrashRecord> permenantDeleteRecords = (List<ZCRMTrashRecord>) module.getPermanentlyDeletedRecords().getData();
示例响应
{
"data": [
{
"deleted_by": {
"name": "Patricia Boyle",
"id": "410888000000086001"
},
"id": "410888000000099071",
"display_name": "Patricia",
"type": "recycle",
"created_by": {
"name": "Patricia Boyle",
"id": "410888000000086001"
},
"deleted_time": "2015-06-19T11:19:38+05:30"
},
{
"deleted_by": {
"name": "Patricia Boyle",
"id": "410888000000086001"
},
"id": "410888000000094004",
"display_name": "Patricia",
"type": "recycle",
"created_by": {
"name": "Patricia Boyle",
"id": "410888000000086001"
},
"deleted_time": "2015-04-07T17:43:33+05:30"
},
{
"deleted_by": null,
"id": "410888000000680013",
"display_name": null,
"type": "permanent",
"created_by": null,
"deleted_time": "2016-10-26T11:44:15+05:30"
},
{
"deleted_by": null,
"id": "410888000000680009",
"display_name": null,
"type": "permanent",
"created_by": null,
"deleted_time": "2016-10-26T11:44:15+05:30"
}
],
"info": {
"per_page": 200,
"count": 4,
"page": 1,
"more_records": false
}
}
示例响应
To get all the deleted Records
$response=ZCRMModule::getInstance($moduleAPIName)->getAllDeletedRecords(); // $moduleAPIName - APIName of the module.
To get All the recyclebin records
$response=ZCRMModule::getInstance($moduleAPIName)->getRecycleBinRecords();
To get all the records which got deleted permanently
$response=ZCRMModule::getInstance($moduleAPIName)->getPermanentlyDeletedRecords();
$records=$response->getData();
try{
foreach ($records as $record){
echo $record->getEntityId();
echo $record->getDisplayName();
echo $record->getType();
$createdBy=$record->getCreatedBy();
$deletedBy=$record->getDeletedBy();
if($createdBy!=null)
{
echo $createdBy->getId();
}
if($deletedBy!=null)
{
echo $deletedBy->getId();
}
echo $record->getDeletedTime();
}
}
catch (ZCRMException $ex)
{
echo $ex->getMessage();
echo $ex->getExceptionCode();
echo $ex->getFile();
}
示例响应
{
"data": [
{
"deleted_by": {
"name": "Patricia Boyle",
"id": "410888000000086001"
},
"id": "410888000000099071",
"display_name": "Patricia",
"type": "recycle",
"created_by": {
"name": "Patricia Boyle",
"id": "410888000000086001"
},
"deleted_time": "2015-06-19T11:19:38+05:30"
},
{
"deleted_by": {
"name": "Patricia Boyle",
"id": "410888000000086001"
},
"id": "410888000000094004",
"display_name": "Patricia",
"type": "recycle",
"created_by": {
"name": "Patricia Boyle",
"id": "410888000000086001"
},
"deleted_time": "2015-04-07T17:43:33+05:30"
},
{
"deleted_by": null,
"id": "410888000000680013",
"display_name": null,
"type": "permanent",
"created_by": null,
"deleted_time": "2016-10-26T11:44:15+05:30"
},
{
"deleted_by": null,
"id": "410888000000680009",
"display_name": null,
"type": "permanent",
"created_by": null,
"deleted_time": "2016-10-26T11:44:15+05:30"
}
],
"info": {
"per_page": 200,
"count": 4,
"page": 1,
"more_records": false
}
}
示例请求
def get_deleted_records(self,delete_type):
try:
module_ins=ZCRMModule.get_instance('Invoices')
if delete_type=='permanent':
resp=module_ins.get_permanently_deleted_records()
elif delete_type=='recycle':
resp=module_ins.get_recyclebin_records()
else: delete_type=='recycle':
resp=module_ins.get_all_deleted_records()
print resp.status_code
trash_record_ins_arr=resp.data
resp_info=resp.info
print resp_info.count
print resp_info.page
print resp_info.per_page
print resp_info.is_more_records
for record_ins in trash_record_ins_arr:
print record_ins.id
print record_ins.type
print record_ins.display_name
if record_ins.created_by is not None:
print record_ins.created_by.id
if record_ins.deleted_by is not None:
print record_ins.deleted_by.id
print record_ins.deleted_time
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": [
{
"deleted_by": {
"name": "Patricia Boyle",
"id": "410888000000086001"
},
"id": "410888000000099071",
"display_name": "Patricia",
"type": "recycle",
"created_by": {
"name": "Patricia Boyle",
"id": "410888000000086001"
},
"deleted_time": "2015-06-19T11:19:38+05:30"
},
{
"deleted_by": {
"name": "Patricia Boyle",
"id": "410888000000086001"
},
"id": "410888000000094004",
"display_name": "Patricia",
"type": "recycle",
"created_by": {
"name": "Patricia Boyle",
"id": "410888000000086001"
},
"deleted_time": "2015-04-07T17:43:33+05:30"
},
{
"deleted_by": null,
"id": "410888000000680013",
"display_name": null,
"type": "permanent",
"created_by": null,
"deleted_time": "2016-10-26T11:44:15+05:30"
},
{
"deleted_by": null,
"id": "410888000000680009",
"display_name": null,
"type": "permanent",
"created_by": null,
"deleted_time": "2016-10-26T11:44:15+05:30"
}
],
"info": {
"per_page": 200,
"count": 4,
"page": 1,
"more_records": false
}
}
示例请求
ZCRMModule moduleIns = ZCRMModule.GetInstance("Leads"); //模块API名称
BulkAPIResponse<ZCRMTrashRecord> response = moduleIns.GetAllDeletedRecords();
List<ZCRMTrashRecord> deletedRecords = response.BulkData; // deletedRecords - list of ZCRMTrashRecord instance both recyclebin records and permanently deleted records
List<ZCRMTrashRecord> recycleBinRecords = moduleIns.GetRecycleBinRecords().BulkData; // To get All the recyclebin records
List<ZCRMTrashRecord> permenantDeleteRecords = moduleIns.GetPermanentlyDeletedRecords().BulkData; //To get all the records which got deleted permanently
示例响应
{
"data": [
{
"deleted_by": {
"name": "Patricia Boyle",
"id": "410888000000086001"
},
"id": "410888000000099071",
"display_name": "Patricia",
"type": "recycle",
"created_by": {
"name": "Patricia Boyle",
"id": "410888000000086001"
},
"deleted_time": "2015-06-19T11:19:38+05:30"
},
{
"deleted_by": {
"name": "Patricia Boyle",
"id": "410888000000086001"
},
"id": "410888000000094004",
"display_name": "Patricia",
"type": "recycle",
"created_by": {
"name": "Patricia Boyle",
"id": "410888000000086001"
},
"deleted_time": "2015-04-07T17:43:33+05:30"
},
{
"deleted_by": null,
"id": "410888000000680013",
"display_name": null,
"type": "permanent",
"created_by": null,
"deleted_time": "2016-10-26T11:44:15+05:30"
},
{
"deleted_by": null,
"id": "410888000000680009",
"display_name": null,
"type": "permanent",
"created_by": null,
"deleted_time": "2016-10-26T11:44:15+05:30"
}
],
"info": {
"per_page": 200,
"count": 4,
"page": 1,
"more_records": false
}
}