×îв©²ÊÍøÕ¾

Java SDK for ×îв©²ÊÍøÕ¾ CRM APIs

The Java SDK for ×îв©²ÊÍøÕ¾ CRM allows developers to easily create Java applications that can be integrated with ×îв©²ÊÍøÕ¾ CRM. It serves as a wrapper for the ×îв©²ÊÍøÕ¾ CRM REST APIs, making it easier to access and utilize the services of ×îв©²ÊÍøÕ¾ CRM.

Authentication to access the CRM APIs is facilitated through OAuth2.0, and the authentication process is streamlined through the use of the Java SDK. The grant and access/refresh tokens are generated and managed within the SDK code, eliminating the need for manual handling during data synchronization between ×îв©²ÊÍøÕ¾ CRM and the client application.

The latest version of Java SDK () supports version 8 of ×îв©²ÊÍøÕ¾ CRM APIs. For more information on the released JAVA SDK versions, refer here.

Prerequisites

  • Ensure that you have a Java development environment set up on your system. with Java version 11 or above.
  • An IDE such as Eclipse or IntelliJ
  • ×îв©²ÊÍøÕ¾ CRM account.

Step 1: Register your application

Before you get started with authorization and make any API calls using the ×îв©²ÊÍøÕ¾ CRM JAVA SDKs, you need to register your application with ×îв©²ÊÍøÕ¾ CRM.

  1. Go to and click on Add Client
  2. Choose the client type as Self Client or Server-based Applications depending on your requirements.
  3. Enter the required credentials.
  4. Click CREATE
  5. Make a note of the Client ID and Client Secret generated for your application.

register a client

Step 2 : Create a project and add Java SDK and dependencies in your project

In this step, you'll create a new Java project in your preferred IDE. We will be using Eclipse IDE in this guide.

  1. Create a new Java project in your IDE.
  2. Add the ×îв©²ÊÍøÕ¾ CRM JAVA SDK and other JARS to your project as a dependency. Please find the downloadable JARs for version 8 SDKs . To install Java SDK supporting version 8 if ×îв©²ÊÍøÕ¾ CRM APIs, install zohocrm-java-sdk-8-0.jar file.

create JAVA project and add dependencies

You can also include the SDK in your project using Maven distribution or Gradle. Please refer to learn more about how to include the ×îв©²ÊÍøÕ¾ CRM Java SDK in your project.

Step 3 : Generation of Grant token

Generate a grant token from the ×îв©²ÊÍøÕ¾ API Console by following the steps described in this page.

generate grant token

Step 4:

In the configuration step, you will set up details such as user authentication, environment, , logging, and API call timeout settings. The following table gives the details of all the keys you can configure, with detailed explanation.

KeyDescriptionSample

mandatory

Represents the domain information to make API calls in Domain.Environment pattern.
Domains: USDataCenter, EUDataCenter, INDataCenter, CNDataCenter, AUDataCenter
Environments: PRODUCTION(), DEVELOPER(), SANDBOX()
environment = USDataCenter.PRODUCTION;

mandatory

Contains user token details. Depending on the tokens, you can choose grantToken flow, refreshToken flow, or accessToken flow. token= new OAuthToken.Builder()
.clientID("clientId")
.clientSecret("clientSecret")
.grantToken("grantToken")
.redirectURL("redirectURL")
.build();

optional

Contains the configuration for logging exceptions and API call information. By default, the logs will be available in the workspace as sdk_logs.log. logger = new Logger.Builder()
.level(Levels.INFO)
.filePath("/Users/java_sdk_log.log")
.build();

optional

Contains details for the Token Persistence object. You can choose between DB Store, File Store, or Custom Store and configure accordingly. To know more about token persistence, refer . tokenstore = new DBStore.Builder()
.host("hostName")
.databaseName("databaseName")
.tableName("tableName")
.userName("userName")
.password("password")
.portNumber("portNumber")
.build();

optional

Contains additional configuration details like timeout, autorefresh fields, picklistvalidation, etc. sdkConfig = new SDKConfig.Builder()
.autoRefreshFields(false)
.pickListValidation(true)
.build();

optional

Contains the details of the proxy if you are using a proxy server to authenticate and make the API calls. requestProxy = new RequestProxy.Builder()
.host("host")
.port(proxyPort)
.user("userName")
.password("password")
.userDomain("userDomain")
.build();

optional

The path containing the absolute directory path to store user-specific files containing the module fields information.

The field metadata for the current user will be fetched and saved in the JSON file. Whenever a user performs a record operation, the data types, picklist values, unique fields etc in the input will be validated against the field metadata stored in the JSON file. In case the user tries to perform a record operation with wrong pick list values, or wrong datatype, it will be caught during this validation stage, and the SDK will throw an error. This will ensure that credits are not consumed for such operations that would anyway result in a failure. In addition to this, the response will also be parsed in the correct format depending on the data in the JSON file.
String resourcePath = "/Users";

For detailed instructions on how to configure the above keys and get started, refer . Find a sample code for initialisation .

SDK initialization

Step 5 : Making requests using Java SDK

After you have configured and initialised, you can start making your API calls. is a sample code to insert a new record in to the Leads module.

Making API calls

Responses and Exceptions

When working with the ×îв©²ÊÍøÕ¾ CRM Java SDK, it is important to understand the responses and exceptions that can be encountered during API calls.

Note:

  • The APIResponse object holds the results of your request. You can access the actual response data using the getObject() method.
  • The APIResponse<ResponseHandler>and APIResponse<ActionHandler> are the common wrapper objects for handling responses from ×îв©²ÊÍøÕ¾ CRM APIs. This depends on the API. For more details, refer .
  • APIException: This exception is thrown for errors that are related to the API itself, such as authentication errors or invalid request parameters.
  • SDKException: This exception is thrown for errors that are related to the ×îв©²ÊÍøÕ¾ CRM SDK, such as network errors or SDK implementation errors.

For more details on the Responses and Exceptions, refer .

Older versions

v7 APIs â–¶

v6 APIs â–¶

v5 APIs â–¶

v4 APIs â–¶

v2.1 APIs â–¶
v2 APIs â–¶