Create Bulk Read job (Bulk Export)
Purpose
To create a bulk read job to export records.
Endpoints
Request Details
Request URL
https://www.zohoapis.com/crm/bulk/v2/read
Header
Authorization: Zoho-oauthtoken d92d4xxxxxxxxxxxxx15f52
Scope
scope=ZohoCRM.bulk.read
(and)
scope=ZohoCRM.modules.{module_name}.{operation_type}
Possible module names
leads, accounts, contacts, deals, campaigns, tasks, cases, events, calls, solutions, products, vendors, price books, quotes, sales orders, purchase orders, invoices, and custom
Possible operation types
ALL - Full access to the record
READ - Get bulk read job
Sample Request
Copiedcurl "https://www.zohoapis.com/crm/bulk/v2/read"
-X POST
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
-H "Content-Type: application/json"
-d "@inputData.json"
CopiedString moduleAPIName = "Leads";
//Get instance of BulkReadOperations Class
BulkReadOperations bulkReadOperations = new BulkReadOperations();
//Get instance of RequestWrapper Class that will contain the request body
RequestWrapper requestWrapper = new RequestWrapper();
//Get instance of CallBack Class
CallBack callback = new CallBack();
// To set valid callback URL.
callback.setUrl("https://www.example.com/callback");
//To set the HTTP method of the callback URL. The allowed value is post.
callback.setMethod(new Choice < String > ("post"));
//The Bulk Read Job's details is posted to this URL on successful completion / failure of job.
requestWrapper.setCallback(callback);
//Get instance of Query Class
Query query = new Query();
//Specifies the API Name of the module to be read.
query.setModule(moduleAPIName);
//Specifies the unique ID of the custom view whose records you want to export.
// query.setCvid("3477061000000087501");
// List of Field API Names
List < String > fieldAPINames = new ArrayList < String > ();
fieldAPINames.add("Last_Name");
//Specifies the API Name of the fields to be fetched.
query.setFields(fieldAPINames);
//To set page value, By default value is 1.
query.setPage(1);
//Get instance of Criteria Class
Criteria criteria = new Criteria();
criteria.setGroupOperator(new Choice < String > ("or"));
List < Criteria > criteriaList = new ArrayList < Criteria > ();
Criteria group11 = new Criteria();
group11.setGroupOperator(new Choice < String > ("and"));
List < Criteria > groupList11 = new ArrayList < Criteria > ();
Criteria group111 = new Criteria();
group111.setAPIName("All_day");
group111.setComparator(new Choice < String > ("equal"));
group111.setValue(false);
groupList11.add(group111);
Criteria group112 = new Criteria();
group112.setAPIName("Owner");
group112.setComparator(new Choice < String > ("in"));
List < String > owner = new ArrayList < String > (Arrays.asList("3477061000000173021"));
group112.setValue(owner);
groupList11.add(group112);
group11.setGroup(groupList11);
criteriaList.add(group11);
Criteria group12 = new Criteria();
group12.setGroupOperator(new Choice < String > ("or"));
List < Criteria > groupList12 = new ArrayList < Criteria > ();
Criteria group121 = new Criteria();
group121.setAPIName("Event_Title");
group121.setComparator(new Choice < String > ("equal"));
group121.setValue("New Automated Event");
groupList12.add(group121);
Criteria group122 = new Criteria();
// To set API name of a field.
group122.setAPIName("Created_Time");
// To set comparator(eg: equal, greater_than.).
group122.setComparator(new Choice < String > ("between"));
List < String > createdTime = new ArrayList < String > (Arrays.asList("2020-06-03T17:31:48+05:30", "2020-06-03T17:31:48+05:30"));
// To set the value to be compare.
group122.setValue(createdTime);
groupList12.add(group122);
group12.setGroup(groupList12);
criteriaList.add(group12);
criteria.setGroup(criteriaList);
//To filter the records to be exported.
query.setCriteria(criteria);
//To set query JSON object.
requestWrapper.setQuery(query);
//Specify the value for this key as "ics" to export all records in the Events module as an ICS file.
//requestWrapper.setFileType(new Choice<String>("ics"));
//Sample request body
// {"query":{"criteria":{"group_operator":"or","group":[{"group_operator":"and","group":[{"comparator":"equal","api_name":"All_day","value":false},
// {"comparator":"in","api_name":"Owner","value":["3477061001"]}]},{"group_operator":"or","group":[{"comparator":"equal","api_name":"Event_Title","value":"New Event"},
// {"comparator":"between","api_name":"Created_Time","value":["2020-06-03T17:31:48+05:30","2020-06-03T17:31:48+05:30"]}]}]},"module":"Events","page":1},
// "callback":{"method":"post","url":"https://www.example.com/callback"}}
//
//Call createBulkReadJob method that takes RequestWrapper instance as parameter
APIResponse < ActionHandler > response = bulkReadOperations.createBulkReadJob(requestWrapper);
Copiedimport javax.net.ssl.SSLContext;
import org.apache.http.HttpEntity;
import org.apache.http.HttpHeaders;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.protocol.HTTP;
import org.apache.http.util.EntityUtils;
import org.json.JSONArray;
import org.json.JSONObject;
public class CreateBulkReadjob
{
@SuppressWarnings("deprecation")
public static void main(String[] args)
{
try
{
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
SSLContext sslContext = SSLContext.getDefault();
SSLConnectionSocketFactory sslConnectionSocketFactory = new SSLConnectionSocketFactory(sslContext, NoopHostnameVerifier.INSTANCE);
CloseableHttpClient httpclient = httpClientBuilder.setSSLSocketFactory(sslConnectionSocketFactory).build();
URIBuilder uriBuilder = new URIBuilder("https://www.zohoapis.com/crm/bulk/v2/read");
HttpUriRequest requestObj = new HttpPost(uriBuilder.build());
HttpEntityEnclosingRequestBase requestBase = (HttpEntityEnclosingRequestBase) requestObj;
JSONObject requestBody = new JSONObject();
JSONObject callback = new JSONObject();
callback.put("url", "https://www.example.com/callback");
callback.put("method", "post");
requestBody.put("callback", callback);
JSONObject query = new JSONObject();
query.put("module", "Contacts");
JSONArray fields = new JSONArray();
fields.put("Last_Name");
fields.put("Owner");
fields.put("Owner.last_name");
fields.put("Account_Name.Account_Name");
fields.put("Account_Name.Phone");
fields.put("Lead_Source");
fields.put("Created_Time");
query.put("fields", fields);
JSONObject criteria = new JSONObject();
criteria.put("group_operator", "or");
JSONArray group = new JSONArray();
JSONObject criteria1 = new JSONObject();
criteria1.put("api_name", "Lead_Source");
criteria1.put("comparator", "equal");
criteria1.put("value", "Advertisement");
group.put(criteria1);
JSONObject criteria2 = new JSONObject();
criteria2.put("api_name", "Owner.last_name");
criteria2.put("comparator", "equal");
criteria2.put("value", "Boyle");
group.put(criteria2);
JSONObject criteria3 = new JSONObject();
criteria3.put("api_name", "Account_Name.Phone");
criteria3.put("comparator", "contains");
criteria3.put("value", "5");
group.put(criteria3);
criteria.put("group", group);
query.put("criteria", criteria);
query.put("page", 1);
requestBody.put("query", query);
requestBase.setEntity(new StringEntity(requestBody.toString(), HTTP.UTF_8));
requestObj.addHeader("Authorization", "Zoho-oauthtoken 1000.xxxxxxx.xxxxxxx");
requestObj.addHeader(HttpHeaders.CONTENT_TYPE, "application/json");
HttpResponse response = httpclient.execute(requestObj);
HttpEntity responseEntity = response.getEntity()
System.out.println("HTTP Status Code : " + response.getStatusLine().getStatusCode());
if(responseEntity != null)
{
Object responseObject = EntityUtils.toString(responseEntity);
String responseString = responseObject.toString();
System.out.println(responseString);
}
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
}
Copied//Get instance of BulkReadOperations Class
$bulkReadOperations = new BulkReadOperations();
//Get instance of RequestWrapper Class that will contain the request body
$requestWrapper = new RequestWrapper();
//Get instance of CallBack Class
$callback = new CallBack();
// To set valid callback URL.
$callback->setUrl("https://www.example.com/callback");
//To set the HTTP method of the callback URL. The allowed value is post.
$callback->setMethod(new Choice("post"));
//The Bulkread Job's details is posted to this URL on successful completion / failure of job.
$requestWrapper->setCallback($callback);
//Get instance of Query Class
$query = new Query();
//Specifies the API Name of the module to be read.
$query->setModule($moduleAPIName);
//Specifies the unique ID of the custom view whose records you want to export.
$query->setCvid("347706187501");
// List of Field API Names
$fieldAPINames = array();
array_push($fieldAPINames, "Last_Name");
//Specifies the API Name of the fields to be fetched.
$query->setFields($fieldAPINames);
//To set page value, By default value is 1.
$query->setPage(1);
//Get instance of Criteria Class
$criteria = new Criteria();
// To set API name of a field.
$criteria->setAPIName("Created_Time");
// To set comparator(eg: equal, greater_than.).
$criteria->setComparator(new Choice("between"));
$createdTime = array("2020-06-03T17:31:48+05:30", "2020-06-03T17:31:48+05:30");
// To set the value to be compare.
$criteria->setValue($createdTime);
//To filter the records to be exported.
$query->setCriteria($criteria);
//To set query JSON object.
$requestWrapper->setQuery($query);
//Specify the value for this key as "ics" to export all records in the Events module as an ICS file.
// $requestWrapper->setFileType(new Choice("ics"));
//Call createBulkReadJob method that takes RequestWrapper instance as parameter
$response = $bulkReadOperations->createBulkReadJob($requestWrapper);
Copied<?php
class CreateBulkReadjob
{
public function execute(){
$curl_pointer = curl_init();
$curl_options = array();
$curl_options[CURLOPT_URL] = "https://www.zohoapis.com/crm/bulk/v2/read";
$curl_options[CURLOPT_RETURNTRANSFER] = true;
$curl_options[CURLOPT_HEADER] = 1;
$curl_options[CURLOPT_CUSTOMREQUEST] = "POST";
$requestBody = array();
$callback = array();
$callback["url"]="https://www.example.com/callback";
$callback["method"]="post";
$query = array();
$query["module"]="Contacts";
$fields = array();
$fields[] = "Last_Name";
$fields[] = "Owner";
$fields[] = "Owner.last_name";
$fields[] = "Account_Name.Account_Name";
$fields[] = "Account_Name.Phone";
$fields[] = "Lead_Source";
$fields[] = "Created_Time";
$requestBody["callback"] =$callback;
$query["fields"]=$fields;
$criteria = array();
$criteria["group_operator"]="or";
$group = array();
$criteria1 = array();
$criteria1["api_name"]="Lead_Source";
$criteria1["comparator"]="equal";
$criteria1["value"]="Advertisement";
$criteria2 = array();
$criteria2["api_name"]="Owner.last_name";
$criteria2["comparator"]="equal";
$criteria2["value"]="Boyle";
$criteria3 = array();
$criteria3["api_name"]="Account_Name.Phone";
$criteria3["comparator"]="contains";
$criteria3["value"]="5";
$group = [$criteria1,$criteria2,$criteria3];
$criteria["group"] = $group;
$query["criteria"] =$criteria;
$query["page"] =1;
$requestBody["query"]=$query;
$curl_options[CURLOPT_POSTFIELDS]= json_encode($requestBody);
$headersArray = array();
$headersArray[] = "Authorization". ":" . "Zoho-oauthtoken " . "1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf";
$headersArray[] = "Content-Type".":"."application/json";
$curl_options[CURLOPT_HTTPHEADER]=$headersArray;
curl_setopt_array($curl_pointer, $curl_options);
$result = curl_exec($curl_pointer);
$responseInfo = curl_getinfo($curl_pointer);
curl_close($curl_pointer);
list ($headers, $content) = explode("\r\n\r\n", $result, 2);
if(strpos($headers," 100 Continue")!==false){
list( $headers, $content) = explode( "\r\n\r\n", $content , 2);
}
$headerArray = (explode("\r\n", $headers, 50));
$headerMap = array();
foreach ($headerArray as $key) {
if (strpos($key, ":") != false) {
$firstHalf = substr($key, 0, strpos($key, ":"));
$secondHalf = substr($key, strpos($key, ":") + 1);
$headerMap[$firstHalf] = trim($secondHalf);
}
}
$jsonResponse = json_decode($content, true);
if ($jsonResponse == null && $responseInfo['http_code'] != 204) {
list ($headers, $content) = explode("\r\n\r\n", $content, 2);
$jsonResponse = json_decode($content, true);
}
var_dump($headerMap);
var_dump($jsonResponse);
var_dump($responseInfo['http_code']);
}
}
(new CreateBulkReadjob())->execute();
Copied//Get instance of BulkReadOperations Class
BulkReadOperations bulkReadOperations = new BulkReadOperations();
//Get instance of RequestWrapper Class that will contain the request body
RequestWrapper requestWrapper = new RequestWrapper();
//Get instance of CallBack Class
CallBack callback = new CallBack();
// To set valid callback URL.
callback.Url = "https://www.example.com/callback";
//To set the HTTP method of the callback URL. The allowed value is post.
callback.Method = new Choice<string> ("post");
//The Bulk Read Job's details is posted to this URL on successful completion / failure of job.
requestWrapper.Callback = callback;
//Get instance of Query Class
API.BulkRead.Query query = new API.BulkRead.Query();
//Specifies the API Name of the module to be read.
query.Module = moduleAPIName;
//Specifies the unique ID of the custom view whose records you want to export.
//query.Cvid = "3477061000000087501";
// List of Field API Names
List<string> fieldAPINames = new List<string>();
fieldAPINames.Add("Last_Name");
//Specifies the API Name of the fields to be fetched.
//query.Fields = fieldAPINames;
//To set page value, By default value is 1.
query.Page = 1;
//Get instance of Criteria Class
Criteria criteria = new Criteria();
criteria.GroupOperator = new Choice<string>("or");
List<Criteria> criteriaList = new List<Criteria>();
Criteria group11 = new Criteria();
group11.GroupOperator = new Choice<string>("and");
List<Criteria> groupList11 = new List<Criteria>();
Criteria group111 = new Criteria();
group111.APIName = "All_day";
group111.Comparator = new Choice<string>("equal");
group111.Value = false;
groupList11.Add(group111);
Criteria group112 = new Criteria();
group112.APIName = "Owner";
group112.Comparator = new Choice<string>("in");
List<string> owner = new List<string>() { "3477061000000173021" };
group112.Value = owner;
groupList11.Add(group112);
group11.Group = groupList11;
criteriaList.Add(group11);
Criteria group12 = new Criteria();
group12.GroupOperator = new Choice<string>("or");
List<Criteria> groupList12 = new List<Criteria>();
Criteria group121 = new Criteria();
group121.APIName = "Event_Title";
group121.Comparator = new Choice<string>("equal");
group121.Value = "New Automated Event";
groupList12.Add(group121);
Criteria group122 = new Criteria();
// To set API name of a field.
group122.APIName = "Created_Time";
// To set comparator(eg: equal, greater_than.).
group122.Comparator = new Choice<string>("between");
List<string> createdTime = new List<string>() { "2020-06-03T17:31:48+05:30", "2020-06-03T17:31:48+05:30" };
// To set the value to be compare.
group122.Value = createdTime;
groupList12.Add(group122);
group12.Group = groupList12;
criteriaList.Add(group12);
criteria.Group = criteriaList;
//To filter the records to be exported.
query.Criteria = criteria;
//To set query JSON object.
requestWrapper.Query = query;
//Specify the value for this key as "ics" to export all records in the Events module as an ICS file.
requestWrapper.FileType = new Choice<string>("csv");
//Call CreateBulkReadJob method that takes RequestWrapper instance as parameter
APIResponse<ActionHandler> response = bulkReadOperations.CreateBulkReadJob(requestWrapper);
Copiedusing System;
using System.IO;
using System.Net;
using System.Text;
using Newtonsoft.Json.Linq;
namespace Com.Zoho.Crm.API.Sample.RestAPI.BulkRead
{
public class CreateBulkReadjob
{
public static void CreateBulkRead()
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://www.zohoapis.com/crm/bulk/v2/read");
request.Method = "POST";
request.ContentType = "application/json";
request.Headers["Authorization"] = "Zoho-oauthtoken 1000.abfeXXXXXXXXXXX2asw.XXXXXXXXXXXXXXXXXXsdc2";
JObject requestBody = new JObject();
JObject callback = new JObject();
callback.Add("url", "https://www.example.com/callback");
callback.Add("method", "post");
requestBody.Add("callback", callback);
JObject query = new JObject();
query.Add("module", "Contacts");
JArray fields = new JArray();
fields.Add("Last_Name");
fields.Add("Owner");
fields.Add("Owner.last_name");
fields.Add("Account_Name.Account_Name");
fields.Add("Account_Name.Phone");
fields.Add("Lead_Source");
fields.Add("Created_Time");
query.Add("fields", fields);
JObject criteria = new JObject();
criteria.Add("group_operator", "or");
JArray group = new JArray();
JObject criteria1 = new JObject();
criteria1.Add("api_name", "Lead_Source");
criteria1.Add("comparator", "equal");
criteria1.Add("value", "Advertisement");
group.Add(criteria1);
JObject criteria2 = new JObject();
criteria2.Add("api_name", "Owner.last_name");
criteria2.Add("comparator", "equal");
criteria2.Add("value", "Boyle");
group.Add(criteria2);
JObject criteria3 = new JObject();
criteria3.Add("api_name", "Account_Name.Phone");
criteria3.Add("comparator", "contains");
criteria3.Add("value", "5");
group.Add(criteria3);
criteria.Add("group", group);
query.Add("criteria", criteria);
query.Add("page", 1);
requestBody.Add("query", query);
string dataString = requestBody.ToString();
var data = Encoding.UTF8.GetBytes(dataString);
int dataLength = data.Length;
request.ContentLength = dataLength;
using (var writer = request.GetRequestStream())
{
writer.Write(data, 0, dataLength);
}
request.KeepAlive = true;
HttpWebResponse response;
try
{
response = (HttpWebResponse)request.GetResponse();
}
catch (WebException e)
{
if (e.Response == null) { throw; }
response = (HttpWebResponse)e.Response;
}
HttpWebResponse responseEntity = response;
Console.WriteLine("HTTP Status Code : " + (int)response.StatusCode);
string responsestring = new StreamReader(responseEntity.GetResponseStream()).ReadToEnd();
responseEntity.Close();
Console.WriteLine(responsestring);
}
}
}
Copied# Get instance of BulkReadOperations Class
bulk_read_operations = BulkReadOperations()
# Get instance of RequestWrapper Class that will contain the request body
request = RequestWrapper()
# Get instance of CallBack Class
call_back = CallBack()
# Set valid callback URL
call_back.set_url("https://www.example.com/callback")
# Set the HTTP method of the callback URL. The allowed value is post.
call_back.set_method(Choice('post'))
# The Bulk Read Job's details is posted to this URL on successful completion / failure of the job.
request.set_callback(call_back)
# Get instance of Query Class
query = Query()
# Specifies the API Name of the module to be read.
query.set_module(module_api_name)
# Specifies the unique ID of the custom view, whose records you want to export.
query.set_cvid('3409643000000087501')
# List of field names
field_api_names = ['Last_Name']
# Specifies the API Name of the fields to be fetched
query.set_fields(field_api_names)
# To set page value, By default value is 1.
query.set_page(1)
# Get instance of Criteria Class
criteria = Criteria()
# To set API name of a field
criteria.set_api_name('Created_Time')
# To set comparator(eg: equal, greater_than)
criteria.set_comparator(Choice('between'))
time = ["2020-06-03T17:31:48+05:30", "2020-06-03T17:31:48+05:30"]
# To set the value to be compared
criteria.set_value(time)
# To filter the records to be exported
query.set_criteria(criteria)
# Set the query object
request.set_query(query)
# Specify the value for this key as "ics" to export all records in the Events module as an ICS file.
# request.set_file_type(Choice('ics'))
# Call create_bulk_read_job method that takes RequestWrapper instance as parameter
response = bulk_read_operations.create_bulk_read_job(request)
Copieddef create_bulk_read_job():
import requests
import json
url = 'https://www.zohoapis.com/crm/bulk/v2/read'
headers = {
'Authorization': 'Zoho-oauthtoken 1000.04be928e4a96XXXXXXXXXXXXX68.0b9eXXXXXXXXXXXX60396e268',
'Content-Type': 'application/json'
}
request_body = dict()
call_back = {
'url': 'https://www.example.com/callback',
'method': 'post'
}
query = {
'module': 'Contacts'
}
fields = [
'Last_Name',
'Owner',
'Account_Name.Account_Name',
'Account_Name.Phone',
'Lead_Source'
]
criteria = {
'group_operator': 'or'
}
criteria_1 = {
'api_name': 'Lead_Source',
'comparator': 'equal',
'value': 'Advertisement'
}
criteria_2 = {
'api_name': 'Owner.last_name',
'comparator': 'equal',
'value': 'Boyle'
}
group = [
criteria_1,
criteria_2
]
criteria['group'] = group
query['criteria'] = criteria
query['page'] = 1
query['fields'] = fields
request_body['query'] = query
request_body['callback'] = call_back
response = requests.post(url=url, headers=headers, data=json.dumps(request_body).encode('utf-8'))
if response is not None:
print("HTTP Status Code : " + str(response.status_code))
print(response.json())
create_bulk_read_job()
Copied//Get instance of BulkReadOperations Class
let bulkReadOperations = new BulkReadOperations();
//Get instance of RequestWrapper Class that will contain the request body
let requestWrapper = new RequestWrapper();
//Get instance of CallBack Class
let callBack = new CallBack();
//Set valid callback URL.
callBack.setUrl("https://www.example.com/callback");
//Set the HTTP method of the callback URL. The allowed value is post.
callBack.setMethod(new Choice("post"));
//The Bulk Read Job's details is posted to this URL on successful completion / failure of the job.
requestWrapper.setCallback(callBack);
//Get instance of Query Class
let query = new Query();
//Specifies the API Name of the module to be read.
query.setModule(moduleAPIName);
//Specifies the unique ID of the custom view, whose records you want to export.
query.setCvid("3409643000000087501");
//Array of field names
let fieldAPINames = [];
fieldAPINames.push("Last_Name");
//Specifies the API Name of the fields to be fetched.
query.setFields(fieldAPINames);
//To set page value, By default value is 1.
query.setPage(1);
//Get instance of Criteria Class
let criteria = new Criteria();
criteria.setGroupOperator(new Choice("or"));
let criteriaArray = [];
let group11 = new Criteria();
group11.setGroupOperator(new Choice("and"));
let groupArray11 = [];
let group111 = new Criteria();
group111.setAPIName("All_Day");
group111.setComparator(new Choice("equal"));
group111.setValue(false);
groupArray11.push(group111);
let group112 = new Criteria();
group112.setAPIName("Owner");
group112.setComparator(new Choice("in"));
group112.setValue(["34770610000001"]);
groupArray11.push(group112);
group11.setGroup(groupArray11);
criteriaArray.push(group11);
// let group112 = new Criteria();
let groupArray12 = [];
// To set API name of a field.
group112.setAPIName("Created_Time");
// To set comparator(eg: equal, greater_than.).
group112.setComparator(new Choice("between"));
let time = ["2020-06-03T17:31:48+05:30", "2020-06-03T17:31:48+05:30"];
// To set the value to be compared
group112.setValue(time);
groupArray12.push(group112);
criteria.setGroup(criteriaArray);
//To filter the records to be exported.
query.setCriteria(criteria);
//Set the query object
requestWrapper.setQuery(query);
//Specify the value for this key as "ics" to export all records in the Events module as an ICS file.
//requestWrapper.setFileType(new Choice("ics"));
//Call createBulkReadJob method that takes RequestWrapper instance as parameter
let response = await bulkReadOperations.createBulkReadJob(requestWrapper);
Copiedasync function createBulkReadJob() {
const got = require('got');
let url = 'https://www.zohoapis.com/crm/bulk/v2/read'
let headers = {
'Authorization': 'Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf',
'Content-Type': 'application/json'
}
let requestBody = {}
let callBack = {
'url': 'https://www.example.com/callback',
'method': 'post'
}
let query = {
'module': 'Contacts'
}
let fields = [
'Last_Name',
'Owner',
'Account_Name.Account_Name',
'Account_Name.Phone',
'Lead_Source'
]
let criteria = {
'group_operator': 'or'
}
let criteria1 = {
'api_name': 'Lead_Source',
'comparator': 'equal',
'value': 'Advertisement'
}
let criteria2 = {
'api_name': 'Owner.last_name',
'comparator': 'equal',
'value': 'Boyle'
}
let group = [criteria1, criteria2]
criteria['group'] = group
query['criteria'] = criteria
query['page'] = 1
query['fields'] = fields
requestBody['query'] = query
requestBody['callback'] = callBack
let requestDetails = {
method : "POST",
headers : headers,
body : JSON.stringify(requestBody),
encoding: "utf8",
throwHttpErrors : false
};
let response = await got(url, requestDetails)
if(response != null) {
console.log(response.statusCode);
console.log(response.body);
}
}
createBulkReadJob()
Copied# """
cvid = '3524033000000087501'
# Get instance of BulkReadOperations Class
bro = BulkRead::BulkReadOperations.new
# Get instance of RequestWrapper Class that will contain the request body
request_wrapper = BulkRead::RequestWrapper.new
# Get instance of CallBack Class
call_back = BulkRead::CallBack.new
# Set valid callback URL
call_back.url = 'https://www.example.com/callback'
# Set the HTTP method of the callback URL. The allowed value is post.
call_back.method = Util::Choice.new('post')
# The Bulk Read Job's details is posted to this URL on successful completion / failure of the job.
request_wrapper.callback = call_back
# Get instance of Query Class
query = BulkRead::Query.new
# Specifies the API Name of the module to be read
query.module = module_api_name
# Specifies the unique ID of the custom view, whose records you want to export.
query.cvid = cvid
# List of field names
field_api_names = ['Last_Name']
# Specifies the API Name of the fields to be fetched
query.fields = field_api_names
# To set page value, By default value is 1.
query.page = 1
# Get instance of Criteria Class
criteria = BulkRead::Criteria.new
# To set API name of a field
criteria.api_name = 'Created_Time'
# To set comparator(eg: equal, greater_than)
criteria.comparator = Util::Choice.new('between')
created_time = ['2020-06-03T17:31:48+05:30', '2020-06-03T17:31:48+05:30']
# To set the value to be compared
criteria.value = created_time
# To filter the records to be exported
query.criteria = criteria
# Set the query object
request_wrapper.query = query
# Specify the value for this key as "ics" to export all records in the Events module as an ICS file.
# request.set_file_type(Util::Choice.new('ics'))
# Call create_bulk_read_job method that takes RequestWrapper instance as parameter
response = bro.create_bulk_read_job(request_wrapper)
Copiedclass CreateBulkReadjob
def execute
url ="https://www.zohoapis.com/crm/bulk/v2/read";
url = URI(url)
req = Net::HTTP::Post.new(url.request_uri)
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
headers={}
headers["Authorization"]="Zoho-oauthtoken 1000.50XXXXXXXXX&77e3a.44XXXXXXXXX8353"
headers["Content-Type"]="application/json";
headers&.each { |key, value| req.add_field(key, value) }
request_body = {};
callback = {}
callback["url"]="https://www.example.com/callback";
callback["method"]="post";
query = {}
query["module"]="Contacts";
fields = ["Last_Name","Owner","Owner.last_name","Account_Name.Account_Name"]
request_body["callback"] =callback;
query["fields"]=fields;
criteria = {}
criteria["group_operator"]="or";
group = {}
criteria1 = {}
criteria1["api_name"]="Lead_Source";
criteria1["comparator"]="equal";
criteria1["value"]="Advertisement";
criteria2 = {}
criteria2["api_name"]="Owner.last_name";
criteria2["comparator"]="equal";
criteria2["value"]="Boyle";
criteria3 = {}
criteria3["api_name"]="Account_Name.Phone";
criteria3["comparator"]="contains";
criteria3["value"]="5";
group = [criteria1,criteria2,criteria3];
criteria["group"] = group;
query["criteria"] =criteria;
query["page"] =1;
request_body["query"]=query;
request_json = request_body.to_json
req.body = request_json.to_s
response=http.request(req)
status_code = response.code.to_i
headers = response.each_header.to_h
print status_code
print headers
unless response.body.nil?
print response.body
end
end
end
CreateBulkReadjob.new.execute
Copied//Get instance of BulkReadOperations Class
let bulkReadOperations = new ZCRM.BulkRead.Operations();
//Get instance of RequestWrapper Class that will contain the request body
let requestWrapper = new ZCRM.BulkRead.Model.RequestWrapper();
//Get instance of CallBack Class
let callBack = new ZCRM.BulkRead.Model.CallBack();
//Set valid callback URL.
callBack.setUrl("https://www.example.com/callback");
//Set the HTTP method of the callback URL. The allowed value is post.
callBack.setMethod(new Choice("post"));
//The Bulk Read Job's details is posted to this URL on successful completion / failure of the job.
requestWrapper.setCallback(callBack);
//Get instance of Query Class
let query = new ZCRM.BulkRead.Model.Query();
//Specifies the API Name of the module to be read.
query.setModule(moduleAPIName);
//Specifies the unique ID of the custom view, whose records you want to export.
// query.setCvid("340964387501");
//Array of field names
let fieldAPINames = [];
fieldAPINames.push("Last_Name");
//Specifies the API Name of the fields to be fetched.
query.setFields(fieldAPINames);
//To set page value, By default value is 1.
query.setPage(1);
//Get instance of Criteria Class
let criteria = new ZCRM.BulkRead.Model.Criteria();
criteria.setGroupOperator(new Choice("or"));
let criteriaArray = [];
let group11 = new ZCRM.BulkRead.Model.Criteria();
group11.setGroupOperator(new Choice("and"));
let groupArray11 = [];
let group111 = new ZCRM.BulkRead.Model.Criteria();
group111.setAPIName("Company");
group111.setComparator(new Choice("equal"));
group111.setValue("Zoho");
groupArray11.push(group111);
let group112 = new ZCRM.BulkRead.Model.Criteria();
group112.setAPIName("Owner");
group112.setComparator(new Choice("in"));
group112.setValue(["3477061173021"]);
groupArray11.push(group112);
group11.setGroup(groupArray11);
criteriaArray.push(group11);
let group12 = new ZCRM.BulkRead.Model.Criteria();
group12.setGroupOperator(new Choice("or"));
let groupArray12 = [];
let group121 = new ZCRM.BulkRead.Model.Criteria();
group121.setAPIName("Email");
group121.setComparator(new Choice("equal"));
group121.setValue("avc6@zoho.com");
groupArray12.push(group121);
let group122 = new ZCRM.BulkRead.Model.Criteria();
// To set API name of a field.
group122.setAPIName("Created_Time");
// To set comparator(eg: equal, greater_than.).
group122.setComparator(new Choice("between"));
let createdTime = [new Date("2020-07-13T12:12:12+05:30"), new Date("2021-07-13T12:12:12+05:30")];
// To set the value to be compared
group122.setValue(createdTime);
groupArray12.push(group122);
group12.setGroup(groupArray12);
criteriaArray.push(group12);
criteria.setGroup(criteriaArray);
//To filter the records to be exported.
query.setCriteria(criteria);
//Set the query object
requestWrapper.setQuery(query);
//Specify the value for this key as "ics" to export all records in the Events module as an ICS file.
//requestWrapper.setFileType(new Choice("ics"));
//Call createBulkReadJob method that takes RequestWrapper instance as parameter
let response = await bulkReadOperations.createBulkReadJob(requestWrapper);
Copiedvar listener = 0;
class CreateBulkReadjob {
async createBulkReadJob() {
var url = "https://www.zohoapis.com/crm/bulk/v2/read"
var parameters = new Map()
var headers = new Map()
var token = {
clientId:"1000.NPY9M1V0XXXXXXXXXXXXXXXXXXXF7H",
redirectUrl:"http://127.0.0.1:5500/redirect.html",
scope:"ZohoCRM.users.ALL,ZohoCRM.bulk.read,ZohoCRM.modules.ALL,ZohoCRM.settings.ALL,Aaaserver.profile.Read,ZohoCRM.org.ALL,profile.userphoto.READ,ZohoFiles.files.ALL,ZohoCRM.bulk.ALL,ZohoCRM.settings.variable_groups.ALL"
}
var accesstoken = await new CreateBulkReadjob().getToken(token)
headers.set("Authorization", "Zoho-oauthtoken " + accesstoken)
headers.set('Content-Type', "application/json")
var requestMethod = "POST"
var reqBody = {
"callback": {
"url": "https://www.example.com/callback",
"method": "post"
},
"query": {
"module": "Contacts",
"fields": [
"Last_Name",
"Owner",
"Owner.last_name",
"Account_Name.Account_Name",
"Account_Name.Phone",
"Lead_Source",
"Created_Time"
],
"criteria": {
"group_operator": "or",
"group": [
{
"api_name": "Lead_Source",
"comparator": "equal",
"value": "Advertisement"
},
{
"api_name": "Owner.last_name",
"comparator": "equal",
"value": "Boyle"
},
{
"api_name": "Account_Name.Phone",
"comparator": "contains",
"value": "5"
}
]
},
"page": 1
}
}
var params = "";
parameters.forEach(function(value, key) {
if (parameters.has(key)) {
if (params) {
params = params + key + '=' + value + '&';
}
else {
params = key + '=' + value + '&';
}
}
});
var apiHeaders = {};
if(headers) {
headers.forEach(function(value, key) {
apiHeaders[key] = value;
});
}
if (params.length > 0){
url = url + '?' + params.substring(0, params.length - 1);
}
var requestObj = {
uri : url,
method : requestMethod,
headers : apiHeaders,
body : JSON.stringify(reqBody),
encoding: "utf8",
allowGetBody : true,
throwHttpErrors : false
};
var result = await new CreateBulkReadjob().makeAPICall(requestObj);
console.log(result.status)
console.log(result.response)
}
async getToken(token) {
if(listener == 0) {
window.addEventListener("storage", function(reponse) {
if(reponse.key === "access_token" && (reponse.oldValue != reponse.newValue || reponse.oldValue == null)){
location.reload();
}
if(reponse.key === "access_token"){
sessionStorage.removeItem("__auth_process");
}
}, false);
listener = 1;
if(sessionStorage.getItem("__auth_process")) {
sessionStorage.removeItem("__auth_process");
}
}
["granted_for_session", "access_token","expires_in","expires_in_sec","location","api_domain","state","__token_init","__auth_process"].forEach(function (k) {
var isKeyExists = localStorage.hasOwnProperty(k);
if(isKeyExists) {
sessionStorage.setItem(k, localStorage[k]);
}
localStorage.removeItem(k);
});
var valueInStore = sessionStorage.getItem("access_token");
var tokenInit = sessionStorage.getItem("__token_init");
if(tokenInit != null && valueInStore != null && Date.now() >= parseInt(tokenInit) + 59 * 60 * 1000){ // check after 59th minute
valueInStore = null;
sessionStorage.removeItem("access_token");
}
var auth_process = sessionStorage.getItem("__auth_process");
if ((valueInStore == null && auth_process == null) || (valueInStore == 'undefined' && (auth_process == null || auth_process == "true"))) {
var accountsUrl = "https://accounts.zoho.com/oauth/v2/auth"
var clientId;
var scope;
var redirectUrl;
if(token != null) {
clientId = token.clientId;
scope = token.scope;
redirectUrl = token.redirectUrl;
}
var fullGrant = sessionStorage.getItem("full_grant");
var grantedForSession = sessionStorage.getItem("granted_for_session");
if(sessionStorage.getItem("__token_init") != null && ((fullGrant != null && "true" == full_grant) || (grantedForSession != null && "true" == grantedForSession))) {
accountsUrl += '/refresh';
}
if (clientId && scope) {
sessionStorage.setItem("__token_init", Date.now());
sessionStorage.removeItem("access_token");
sessionStorage.setItem("__auth_process", "true");
window.open(accountsUrl + "?" + "scope" + "=" + scope + "&"+ "client_id" +"=" + clientId + "&response_type=token&state=zohocrmclient&redirect_uri=" + redirectUrl);
["granted_for_session", "access_token","expires_in","expires_in_sec","location","api_domain","state","__token_init","__auth_process"].forEach(function (k) {
var isKeyExists = localStorage.hasOwnProperty(k);
if(isKeyExists){
sessionStorage.setItem(k, localStorage[k]);
}
localStorage.removeItem(k);
});
valueInStore = sessionStorage.getItem("access_token");
}
}
if(token != null && valueInStore != 'undefined'){
token.accessToken = valueInStore;
}
return token.accessToken;
}
async makeAPICall(requestDetails) {
return new Promise(function (resolve, reject) {
var body, xhr, i;
body = requestDetails.body || null;
xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.open(requestDetails.method, requestDetails.uri, true);
for (i in requestDetails.headers) {
xhr.setRequestHeader(i, requestDetails.headers[i]);
}
xhr.send(body);
xhr.onreadystatechange = function() {
if(xhr.readyState == 4) {
resolve(xhr);
}
}
})
}
}
Copied//Get instance of BulkReadOperations Class
let bulkReadOperations: BulkReadOperations = new BulkReadOperations();
//Get instance of RequestWrapper Class that will contain the request body
let requestWrapper: RequestWrapper = new RequestWrapper();
//Get instance of CallBack Class
let callBack: CallBack = new CallBack();
//Set valid callback URL.
callBack.setUrl("https://www.example.com/callback");
//Set the HTTP method of the callback URL. The allowed value is post.
callBack.setMethod(new Choice("post"));
//The Bulk Read Job's details is posted to this URL on successful completion / failure of the job.
requestWrapper.setCallback(callBack);
//Get instance of Query Class
let query: Query = new Query();
//Specifies the API Name of the module to be read.
query.setModule(moduleAPIName);
//Specifies the unique ID of the custom view, whose records you want to export.
query.setCvid("3477061087501");
//Array of field names
let fieldAPINames: string[] = [];
fieldAPINames.push("Last_Name");
//Specifies the API Name of the fields to be fetched.
query.setFields(fieldAPINames);
//To set page value, By default value is 1.
query.setPage(1);
//Get instance of Criteria Class
let criteria: Criteria = new Criteria();
criteria.setGroupOperator(new Choice("or"));
let criteriaArray: Criteria[] = [];
let group11: Criteria = new Criteria();
group11.setGroupOperator(new Choice("and"));
let groupArray11: Criteria[] = [];
let group111: Criteria = new Criteria();
group111.setAPIName("Company");
group111.setComparator(new Choice("equal"));
group111.setValue("Zoho");
groupArray11.push(group111);
let group112: Criteria = new Criteria();
group112.setAPIName("Owner");
group112.setComparator(new Choice("in"));
group112.setValue(["3477061173021"]);
groupArray11.push(group112);
group11.setGroup(groupArray11);
criteriaArray.push(group11);
let group12 = new Criteria();
group12.setGroupOperator(new Choice("or"));
let groupArray12: Criteria[] = [];
let group121 = new Criteria();
group121.setAPIName("Paid");
group121.setComparator(new Choice("equal"));
group121.setValue(true);
groupArray12.push(group121);
let group122 = new Criteria();
// To set API name of a field.
group122.setAPIName("Created_Time");
// To set comparator(eg: equal, greater_than.).
group122.setComparator(new Choice("between"));
let time = ["2020-06-03T17:31:48+05:30", "2020-06-03T17:31:48+05:30"];
// To set the value to be compared
group122.setValue(time);
groupArray12.push(group122);
group12.setGroup(groupArray12);
criteriaArray.push(group12);
criteria.setGroup(criteriaArray);
//To filter the records to be exported.
query.setCriteria(criteria);
//Set the query object
requestWrapper.setQuery(query);
//Specify the value for this key as "ics" to export all records in the Events module as an ICS file.
//requestWrapper.setFileType(new Choice("ics"));
//Call createBulkReadJob method that takes RequestWrapper instance as parameter
let response: APIResponse < ActionHandler > = await bulkReadOperations.createBulkReadJob(requestWrapper);
Copiedimport got from 'got';
class CreateBulkReadjob {
public async main() {
var apiHeaders: {[key: string]: string} = {};
var apiParameters: {[key: string]: string} = {};
var modifiedRequestBody: any={
"callback": {
"url": "https://www.example.com/callback",
"method": "post"
},
"query": {
"module": "Contacts",
"fields": [
"Last_Name",
"Owner",
"Owner.last_name",
"Account_Name.Account_Name",
"Account_Name.Phone",
"Lead_Source",
"Created_Time"
],
"criteria": {
"group_operator": "or",
"group": [
{
"api_name": "Lead_Source",
"comparator": "equal",
"value": "Advertisement"
},
{
"api_name": "Owner.last_name",
"comparator": "equal",
"value": "Boyle"
},
{
"api_name": "Account_Name.Phone",
"comparator": "contains",
"value": "5"
}
]
},
"page": 1
}
};
modifiedRequestBody = JSON.stringify(modifiedRequestBody)
apiHeaders["Content-Type"]= "application/json"
apiHeaders["Authorization"] = "Zoho-oauthtoken 1000.xxxxxxx.xxxxxx"
var requestDetails: {[key: string]: any} = {
method : "POST",
headers : apiHeaders,
searchParams : apiParameters,
body : modifiedRequestBody,
encoding: "utf8",
allowGetBody : true,
throwHttpErrors : false
};
var response = await got("https://www.zohoapis.com/crm/bulk/v2/read", requestDetails);
console.log(response.statusCode)
console.log(JSON.parse(response.body));
}
}
var v = new CreateBulkReadjob()
v.main()
Request JSON
- callbackJSON Object, optional
The JSON object represents the following details of a bulk read job.
- url(string)-
A valid URL, that should allow HTTP Post method. The Bulk Read Job's details is posted to this URL on successful completion of job or on failure of job. - method(string)-
The HTTP method of the callback url. The supported value is post.
- url(string)-
- file_type(string, mandatory when you want to export the events as an ICS file)
Specify the value for this key as "ics" to export all records in the Events module as an ICS file.
- queryJSON Object, optional
Represents the JSON object that holds the keys and their value that form the criteria for bulk export. The following are the keys in the JSON object:
- module(string, mandatory)-
Represents the API Name of the module you want to export the records from. For instance, Leads. Specify the module name as "Events" if you want to export the records in the Events module as an ICS file. - cvid(string, optional) -
Represents the unique ID of the custom view when you want to export records in a custom view. You can obtain the cvid from the Custom View Metadata API. - fields(JSON array, optional) -
Represents the API name of the fields that you want to export. For instance, First_Name, Last_Name, Email, Owner.last_name, and so on. Do not input this key when you want to export the records in the Events module as an ICS file. - page(integer, optional) -
The default value is 1 and means that the first 200,000 records matching your query will get exported. If you want to fetch the records from the range 200,001 to 400,000, then mention the value as '2'. - criteria(JSON object, optional) -
Represents the details that the system uses to filter records.Ex: The API Name of a module or field, comparators used to add two or more criteria, a group which the record/module/field belongs to etc. the following are the keys of this JSON object:- group_operator(string, mandatory if api_name, comparator and value are not specified) -
Represents the Logical operators. Supported values - and, or. - group(JSON array, mandatory if api_name, comparator and value are not specified) -
Represents the array of criteria objects. Each object in the criteria has the following keys:- api_name(string, mandatory if group and group_operator are not specified)-
Here in this example the key is given as a part of "group" JSON array. You can also specify it directly inside the criteria JSON object. The key represents the API name of a field to be compared. For instance: First_Name, Last_Name, Owner.last_name etc. - value(string/JSON array, mandatory if group and group_operator are not specified)-
Here in this example the key is given as a part of "group" JSON array. You can also specify it directly inside the criteria JSON object. The key represents the value with which the records must be filtered. - comparator(string, mandatory if group and group_operator are not specified.)-
Here in this example the key is given as a part of "group" JSON array. You can also specify it directly inside the criteria JSON object. The key represents the comparator. Example: equal, greater_than. The following table shows the supported comparators.
- api_name(string, mandatory if group and group_operator are not specified)-
- group_operator(string, mandatory if api_name, comparator and value are not specified) -
- module(string, mandatory)-
Allowed Comparators
Data type | Comparator | Value and limits |
---|---|---|
Number(Integer)/Decimal/BigInteger/ Currency/Percent | equal, not_equal, in, not_in, less_than, less_equal, greater_than, greater_equal | Any number values or ${EMPTY} for an empty value. Not more than 19 digits for big integer, decimal values for decimal and currency fields. In multi-currency enabled accounts, only the home currency value is supported. |
Text (Email, Phone, URL, Picklist, Multi-select, etc) | equal, not_equal, in, not_in, contains, not_contains, starts_with, ends_with | Any text values or ${EMPTY} for empty value. Not more than 255 characters. |
Date and DateTime | equal, not_equal, in, not_in, between, not_between, greater_than, greater_equal, less_than, less_equal | Any date values in the ISO 8601 format or ${EMPTY} for an empty value. For DateTime fields, milliseconds is not supported. |
Boolean | equal | True or false. |
Lookup | equal, not_equal, in, not_in | Big integer value of the lookup, ${EMPTY} for empty value, or use the .(dot) operator to establish a relation between two modules. Example: "Owner" fetches the ID of the Owner, whereas "Owner.last_name" fetches the last name of the owner. "Account_Name" fetches the ID of the Account associated with the base module, whereas "Account_Name.Phone" fetches the phone number of the account associated with the base module. |
Sample Input with lookup fields
Copied{
"callback": {
"url": "https://www.example.com/callback",
"method": "post"
},
"query": {
"module": "Contacts",
"fields": [
"Last_Name",
"Owner",
"Owner.last_name",
"Account_Name.Account_Name",
"Account_Name.Phone",
"Lead_Source",
"Created_Time"
],
"criteria": {
"group_operator": "or",
"group": [
{
"api_name": "Lead_Source",
"comparator": "equal",
"value": "Advertisement"
},
{
"api_name": "Owner.last_name",
"comparator": "equal",
"value": "Boyle"
},
{
"api_name": "Account_Name.Phone",
"comparator": "contains",
"value": "5"
}
]
},
"page": 1
}
}
This query fetches records based on the specified criteria and the "."(dot) operator is used to fetch data from the parent modules. Account_Name is the default lookup field in the Contacts module. Here, Owner.last_name returns the last name of the owner of the contact, Account_Name returns the ID and Account_Name.Account_Name returns the name of the account associated with the contact, and Account_Name.Phone returns the phone number of the account associated with the contact.
Sample input with cvid and criteria
Copied{
"callback": {
"url": "https://www.example.com/callback",
"method": "post"
},
"query": {
"module": "Leads",
"cvid": "554023000000093005",
"fields": [
"Last_Name",
"Owner",
"Owner.last_name",
"$converted",
"Lead_Source",
"Lead_Status",
"Company",
"Email",
"Mobile",
"Created_Time"
],
"criteria": {
"api_name": "Owner.last_name",
"comparator": "equal",
"value": "Patricia Boyle"
}
}
}
Sample input to export meetings in the ICS format
Copied{
"query": {
"module": "Events",
"criteria": {
"group": [
{
"group": [
{
"api_name": "All_day",
"comparator": "equal",
"value": "false"
},
{
"api_name": "Owner",
"comparator": "in",
"value": [
"554023000000695002",
"554023000000691003"
]
}
],
"group_operator": "and"
},
{
"api_name": "Created_Time",
"comparator": "greater_equal",
"value": "2019-10-14T15:30:00+05:30"
}
],
"group_operator": "or"
}
},
"file_type": "ics"
}
Response Structure
- statusstring
Specifies the status of the API call. Sample - "status": "success".
- messagestring
Specifies the pre-defined comments for the job. Useful in case any errors occur. Sample - "message": "Added successfully."
- detailsJSON object
Contains the following details of the bulk read job.
- operation(string)-
Specifies the type of action the API completed. Sample - "operation" : "read”. - created_by(JSON object)-
Specifies the ID and Name of the user who initiated the bulk read job. Sample - "created_by": { "id": "1000000031045", "name": "Patricia Boyle" }. - created_time (JSON object)-
Specifies the created time of the bulk read job. - state(string)-
Specifies the current status of the bulk read job. Example: "state": "ADDED" or "IN PROGRESS" or "COMPLETED". - id(string)-
Specifies the unique identifier of the bulk read job. Use this ID to check the job status and download the result. Sample - "id": "1000010760002".
- operation(string)-
Sample response
Copied{
"data": [
{
"status": "success",
"code": "ADDED_SUCCESSFULLY",
"message": "Added successfully.",
"details": {
"id": "554023000000568002",
"operation": "read",
"state": "ADDED",
"created_by": {
"id": "554023000000235011",
"name": "Patricia Boyle"
},
"created_time": "2019-05-09T14:01:24+05:30"
}
}
],
"info": {}
}
Note
- A maximum of two hundred thousand records can be exported in a single export job. i.e, "page" would be "1" and the records in the page would be "200,000". To know more about the Bulk API limits, go here.
- The first 200,000 records matching the criteria are taken for export if the value of the "page" is "1".
- To fetch data from parent modules, use the "."(dot) operator. For example, Contacts module has the default Account_Name lookup field. To fetch the name of the account that the contact is associated with, use Contacts.Account_Name.Account_Name.
- Use only API names of fields and modules in the input.
- If the "fields" attribute in the query JSON is left empty, all the fields available for the corresponding base module are listed in the CSV file. In case you need only specific fields, specify the field API names for export.
- It is mandatory to specify the cvid if you want to export records under a custom view.
- Along with cvid, you can also specify additional criteria. These criteria will be appended with the existing criteria for the custom/standard view.
For ICS file type
- Exporting records in ICS format is supported only for the Meetings module.
- You can export a maximum of 20,000 records from the Meetings module per batch.
- The "fields" attribute is not supported when you want to export the meetings as an ICS file.
- If you do not specify "file_type" as "ics", the records will be exported in the CSV format, by default.
- If the value of more_records is "true" in the response of the Get Job Details API call, there are more records to be fetched.
Sample callback for job completed
Copied{
"job_id": "554023000000568002",
"operation": "read",
"state": "COMPLETED",
"query": {
"module": "Leads",
"criteria": {
"group": [
{
"api_name": "$converted",
"comparator": "equal",
"value": true
},
{
"api_name": "Owner.last_name",
"comparator": "equal",
"value": "Patricia Boyle"
}
],
"group_operator": "and"
},
"page": 1,
"fields": [
"Last_Name",
"Owner",
"Owner.last_name",
"$converted",
"Lead_Source",
"Lead_Status",
"Company",
"Email",
"Mobile",
"Created_Time"
],
"cvid": "554023000000093005"
},
"result": {
"page": 1,
"count": 1588,
"download_url": "/crm/bulk/v2/read/554023000000568002/result",
"per_page": 200000,
"more_records": false
}
}
Possible Errors
- MEDIA_TYPE_NOT_SUPPORTEDHTTP 415
Media type is not supported.
Resolution: You have not passed the 'Content-Type' header along with the request. - 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 ZohoCRM.bulk.read or ZohoCRM.modules.{module_name}.READ. Create a new client with valid scope. Refer to scope section above. - NO_PERMISSIONHTTP 403
Permission denied to read
Resolution: The user does not have permission to read records. 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.
Resolution: The user does not have the permission to read records. Contact your system administrator.
Sample callback for job failed
Copied{
"job_id": "554023000000568002",
"operation": "read",
"state": "FAILURE",
"query": {
"module": "Leads",
"criteria": {
"group": [
{
"api_name": "$converted",
"comparator": "equal",
"value": true
},
{
"api_name": "Owner.last_name",
"comparator": "equal",
"value": "Patricia Boyle"
}
],
"group_operator": "and"
},
"page": 1,
"fields": [
"Last_Name",
"Owner",
"Owner.last_name",
"$converted",
"Lead_Source",
"Lead_Status",
"Company",
"Email",
"Mobile",
"Created_Time"
],
"cvid": "554023000000093005"
},
"result": {
"error_message": {
"message": "<error message>",
"details": "<detailed messages>",
"status": "error",
"code": "<ERROR CODE>"
}
}
}