Zoho Request Client (ZRC)

Developer reference for class definitions, schemas, and code snippets across NodeJS, Python, and Java.

 

Node.js

Schema

RequestConfig

TypeScript

 

type RequestConfig = {
  headers: object, // key-value pairs to be sent as headers
  connection: string, // connection name (for connection-based requests)
  baseUrl: string, // base URL for REST API calls
  responseType: 'JSON' | 'STREAM' | 'TEXT' | 'ARRAY_BUFFER' | 'BUFFER',
  params: object, // key-value pairs sent as query params
  scope: 'system' | 'user' // default: 'system'
}

ZRC

Class

 

class ZRC {
  // Instance factory
  createInstance(requestConfig) → ZRC
  // Instance methods (uses constructor config)
  get(path) → Promise<ZrcResponse>
  post(path, body) → Promise<ZrcResponse>
  put(path, body, requestConfig) → Promise<ZrcResponse>
  patch(path, body) → Promise<ZrcResponse>
  delete(path, body) → Promise<ZrcResponse>
  head(path) → Promise<ZrcResponse>
  options(path) → Promise<ZrcResponse>
  // Static methods (pass config explicitly)
  static get(path, requestConfig) → Promise<ZrcResponse>
  static post(path, body, requestConfig) → Promise<ZrcResponse>
  static put(path, body) → Promise<ZrcResponse>
  static patch(path, body, requestConfig) → Promise<ZrcResponse>
  static delete(path, body, requestConfig) → Promise<ZrcResponse>
  static head(path, requestConfig) → Promise<ZrcResponse>
  static options(path, requestConfig) → Promise<ZrcResponse>
}

ZrcResponse

TypeScript

 

type ZrcResponse = {
  status: number,
  headers: object,
  data: object
}

Code Snippets

Import

 

const { ZRC } = require('zrc');

CRM Request

 

// Default — no connection or baseUrl needed for CRM calls
const response = await ZRC.get("/crm/v2/Leads");

Connection Request

 

// Pass connection name + baseUrl in config
const response = await ZRC.get("/crm/v2/Leads", {
  connection: "zohocrm",
  baseUrl: "https://www.crm.zoho.com"
});

REST API Methods

 

// GET — full URL
const getResponse = await ZRC.get('https://www.example.com/products');
// GET — path + baseUrl
const getAlt = await ZRC.get('/products', { baseUrl: 'https://www.example.com' });
// GET — with query params
const getWithParams = await ZRC.get('/products', {
  baseUrl: 'https://www.example.com',
  params: { q: 'phone' }
});
// POST
const postResponse = await ZRC.post('/products/add', { title: 'Apple' }, { baseUrl: 'https://www.example.com' });
// PUT
const putResponse = await ZRC.put('/products/1', { title: 'Mi' }, { baseUrl: 'https://www.example.com' });
// PATCH
const patchResponse = await ZRC.patch('/products/1', { title: 'MicroMax' }, { baseUrl: 'https://www.example.com' });
// DELETE
const deleteResponse = await ZRC.delete('/products/1', null, { baseUrl: 'https://www.example.com' });

User Scope

 

// Pass scope: "user" in config — default is "system"
const response = await ZRC.post("/crm/v2/Leads", {
  data: [{ Last_Name: "Arul" }]
}, {
  scope: "user"
});
basicIO.write(response.data);
basicIO.write(response.status);

Python

Class Definition

RequestConfig

Class

 

class RequestConfig:
  def __init__(self):
    self.base_url = ''
    self.headers = {}
    self.params = {}
    self.response_type = 'json'
    self.proxy_config = None
    self.connection_timeout = None
    self.socket_timeout = None
    self.connection = None
  def set_base_url(self, base_url): ...
  def set_headers(self, headers): ...
  def set_params(self, params): ...
  def set_response_type(self, t): ...
  def set_proxy_config(self, cfg): ...
  def set_connection_timeout(self, t): ...
  def set_socket_timeout(self, t): ...
  def set_connection(self, conn): ...

ZrcResponse

Class

 

class ZrcResponse:
  def __init__(self, status_code, headers, body):
    self.status_code = status_code
    self.headers = headers
    self.body = body
  def getStatus(self): return self.status_code
  def getHeaders(self): return self.headers
  def getBody(self): return self.body

ZRC

Class

 

class ZRC:
  def __init__(self, request_config): ...
  # Instance factory
  @staticmethod
  def createInstance(request_config) → ZRC
  # Static methods
  @staticmethod
  def get(path, request_config) → ZrcResponse
  @staticmethod
  def post(path, body, request_config) → ZrcResponse
  @staticmethod
  def put(path, body, request_config) → ZrcResponse
  @staticmethod
  def patch(path, body, request_config) → ZrcResponse
  @staticmethod
  def delete(path, request_config) → ZrcResponse
  @staticmethod
  def head(path, request_config) → ZrcResponse
  @staticmethod
  def options(path, request_config) → ZrcResponse
  # Instance methods (UPPERCASE aliases)
  def GET(self, path) → ZrcResponse
  def POST(self, path, body) → ZrcResponse
  def PUT(self, path, body) → ZrcResponse
  def PATCH(self, path, body) → ZrcResponse
  def DELETE(self, path) → ZrcResponse
  def HEAD(self, path) → ZrcResponse
  def OPTIONS(self, path) → ZrcResponse

Code Snippets

Import

 

from zrc import ZRC, RequestConfig, FormData

GET Request

 

config = RequestConfig()
config.set_base_url('http://localhost:3000')
config.set_headers({'Content-Type': 'application/json'})
response = ZRC.get('/items', config)
assert response.status_code == 200

POST Request with FormData

 

config = RequestConfig()
config.set_base_url('http://localhost:3000')
config.set_headers({'Content-Type': 'multipart/form-data'})
form_data = FormData()
form_data.append('field1', 'value1')
form_data.append('field2', 'value2')
response = ZRC.post('/items', form_data, config)
assert response.status_code == 201

PUT / PATCH / DELETE

 

config = RequestConfig()
config.set_base_url('http://localhost:3000')
config.set_headers({'Content-Type': 'application/json'})
# PUT
response = ZRC.put('/items/1', {"field1": "alex"}, config)
# PATCH
response = ZRC.patch('/items/1', {"field1": "alex"}, config)
# DELETE — set response_type as needed
config.set_response_type('text')
response = ZRC.delete('/items/1', config)

CRM Integration Call

 

# No baseUrl needed — ZRC resolves CRM endpoint automatically
config = RequestConfig()
config.set_response_type('json')
response = ZRC.delete('/crm/v2/Leads', config)

Connection Call

 

config = RequestConfig()
config.set_base_url('https://www.crm.zoho.com')
config.set_headers({'Content-Type': 'application/json'})
config.set_connection("zohocrm") # connection name
response = ZRC.get('/crm/v2/Leads', config)

Java

Class Definition

RequestConfig

Class

 

public class RequestConfig {
  private String baseUrl;
  private ResponseType responseType;
  private Map<String,String> headers;
  private Map<String,String> params;
  private TypeReference<?> typeReference;
  private String scope = "system"; // "system" | "user"
  // Getters / setters
  public String getBaseUrl() { ... }
  public void setBaseUrl(String url) { ... }
  public ResponseType getResponseType() { ... }
  public void setResponseType(ResponseType t) { ... }
  public void addHeader(String k, String v) { ... }
  public void addParam(String k, String v) { ... }
  public void setConnection(String name) { ... }
  public void setScope(String scope) { ... }
  public RequestConfig setTypeReference(TypeReference<?> ref) { ... }
  public TypeReference<?> getTypeReference() { ... }
}

ZrcResponse<T>

Class

 

public class ZrcResponse<T> {
  private int status;
  private Map<String,String> headers;
  private T data;
  public ZrcResponse(int status,
                     Map<String,String> headers,
                     T data) { ... }
  public int getStatus() { ... }
  public Map<String,String> getHeaders() { ... }
  public T getData() { ... }
  public void setStatus(int s) { ... }
  public void setHeaders(Map<String,String> h) { ... }
}

ZRC

Abstract Class

 

public class ZRC {
  public static ZRC create(RequestConfig config) → ZrcClient
  public <T> ZrcResponse<T> get(String path) throws Exception
  public <T> ZrcResponse<T> post(String path, Object body) throws Exception
  public <T> ZrcResponse<T> put(String path, Object body) throws Exception
  public <T> ZrcResponse<T> patch(String path, Object body) throws Exception
  public <T> ZrcResponse<T> delete(String path) throws Exception
  public <T> ZrcResponse<T> delete(String path, Object body) throws Exception
  public <T> ZrcResponse<T> head(String path) throws Exception
  public <T> ZrcResponse<T> options(String path, String body) throws Exception
  public <T> ZrcResponse<T> request(HttpMethods method, String path, Object body, RequestConfig config) throws Exception
}

ZrcClient

Implementation

 

public class ZrcClient {
  RequestConfig requestConfig;
  // GET
  public <T> ZrcResponse<T> get(String path) throws ...
  public <T> ZrcResponse<T> get(String path, RequestConfig config) throws ...
  // POST
  public <T> ZrcResponse<T> post(String path) throws ...
  public <T> ZrcResponse<T> post(String path, Object body) throws ...
  public <T> ZrcResponse<T> post(String path, Object body, RequestConfig config) throws ...
  // PUT
  public <T> ZrcResponse<T> put(String path) throws ...
  public <T> ZrcResponse<T> put(String path, Object body) throws ...
  public <T> ZrcResponse<T> put(String path, Object body, RequestConfig config) throws ...
  // PATCH
  public <T> ZrcResponse<T> patch(String path) throws ...
  public <T> ZrcResponse<T> patch(String path, Object body) throws ...
  public <T> ZrcResponse<T> patch(String path, Object body, RequestConfig config) throws ...
  // DELETE
  public <T> ZrcResponse<T> delete(String path) throws ...
  public <T> ZrcResponse<T> delete(String path, RequestConfig config) throws ...
  // HEAD / OPTIONS
  public <T> ZrcResponse<T> head(String path) throws ...
  public <T> ZrcResponse<T> head(String path, RequestConfig config) throws ...
  public <T> ZrcResponse<T> options(String path) throws ...
  public <T> ZrcResponse<T> options(String path, String body) throws ...
  public <T> ZrcResponse<T> options(String path, String body, RequestConfig config) throws ...
  // request(...) overloads
  public <T> ZrcResponse<T> request(HttpMethods method, String path) throws ...
  public <T> ZrcResponse<T> request(HttpMethods method, String path, Object body) throws ...
  public <T> ZrcResponse<T> request(HttpMethods method, String path, Object body, RequestConfig config) throws ...
  public <T> ZrcResponse<T> request(PayLoadRequestConfig config) throws ...
}

Code Snippets

Setup RequestConfig

 

RequestConfig config = new RequestConfig();
/** Base URL **/
config.setBaseUrl(baseUrl);
/** Response type **/
config.setResponseType(ResponseType.JSON);
/** Type mapping (JSON only) **/
config.setTypeReference(new TypeReference<Item>(){});
/** Headers & params **/
config.addHeader("CustomHeaders", "Abcd");
config.addParam("xyz", "abcd");
/** Connection name **/
config.setConnection("zohocrm");
/** Scope — "user" | "system" (default: system, for integration calls only) **/
config.setScope("user");

CRM Call

 

/** No baseUrl or connection needed — CRM endpoint resolved automatically **/
RequestConfig config = new RequestConfig();
config.setTypeReference(new TypeReference<JSONObject>(){});
ZrcResponse<JSONObject> leadsResponse = ZRC.get("/crm/v2/leads", config);

POST with FormData

 

FormData formData = new FormData();
formData.append("title", "foo");
formData.append("body", "bar");
formData.append("userId", "1");
formData.append("file", byteArray, "abcd.txt", MimeTypes.TEXT_PLAIN.getMimeType());
ZrcResponse<Item> response = ZRC.post("/items", formData, config);
if (response.getStatus() == 200) {
  Item item = response.getData();
  // further handling
}

GET / PUT / PATCH / DELETE / Stream

 

// GET
ZrcResponse<Item> getResp = ZRC.get("/items/1", config);
// PUT
config.setTypeReference(new TypeReference<JSONObject>(){});
ZrcResponse<JSONObject> putResp = ZRC.put("/items/1",
  new JSONObject().put("title", "fooo").put("body", "barr").put("userId", 1),
  config);
// PATCH
ZrcResponse<JSONObject> patchResp = ZRC.patch("/items/1",
  new JSONObject().put("title", "fx"),
  config);
// DELETE
config.setTypeReference(null);
ZrcResponse delResp = ZRC.delete("/items/1", config);
// Stream response
ZrcResponse<InputStream> streamResp = ZRC.get("/stream", config);

Error Handling

 

try {
  // ... ZRC calls ...
} catch (ApiError | ConnectionError | ZrcError | ZrcValidationError e) {
  basicIO.write(e);
}