Kaizen Java SDK Version 5.0

Kaizen Java SDK Version 5.0

Hello, everyone! Welcome to another Kaizen week. In this post, we will discuss how third-party applications can integrate with Zoho CRM using Java SDK 5.0.

Use case 

Zylker is a real-estate app which can integrate with any CRM vendor and uses that data for it's use-cases. Zylker uses Java for the backend server code. Now they want to integrate with Zoho CRM.  How will they do it? Those users could be in different Zoho data centers like Europe (.eu), USA(.com), India(.in), Australia(.com.au) etc. With Zoho CRM's Java SDK 5.0, which consumes Zoho CRM v5 APIs, we can to do authorization and establish this integration. Zylker will write one common code and it should be usable for any CRM orgs across all DCs. 

Java SDK Project dependency

Include the Java dependency using either Maven or Gradle. The maven dependency is as below:

<repositories>
<repository>
<id>zohocrmsdk-5-0</id>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.zoho.crm</groupId>
<artifactId>zohocrmsdk-5-0</artifactId>
<version>4.0.0</version>
</dependency>
</dependencies>


If you are not using Maven or Gradle, please include the Zoho CRM Java SDK JAR and dependant JARs directly into the Java build path.

Setting up the OAuth client 

Create a Server-based Application in the corresponding API console page (https://www.zohoapis.{com/in/eu/com.au}). Enable "Multi-DC" under Settings of the app. Choose "Use the same OAuth credentials for all data centers". With this, you can use the same client ID, client secret, and redirect URI to authorize any Zoho account in any data center. Please refer to our previous posts to know more about domains and environments [Part -1] and [Part - 2].

Integrating the client with your application

In Zylker's web UI, there will be an option to integrate with Zoho CRM. The integration can be initiated from a link or a button containing the authorization URL, along with the corresponding client ID, state, redirect URI, and OAuth scopes. Once the user clicks on this link/button and completes the OAuth authorization process on Zoho, they will be redirected to the specified redirect URI with HTTP parameters location, code, accounts server, and state. These parameters can be utilized within the Java code logic of the redirect URI to begin using the Zoho CRM Java SDK.
The codes used in this post are hosted here for reference. We will focus on two distinct steps as mentioned below, for Zylker integration with Zoho CRM using Java SDK.
     1.  Authorize with Zoho CRM
     2. Fetching data from Zoho CRM

1. Authorize with Zoho CRM 

The aim of this step is to connect with the user's Zoho CRM and store the token details such as refresh token, access token and expiry time in the preferred datastore like MySQL, pgSQL etc. Once the user lands on the redirect URI after the OAuth2.0 authorization, we can extract the email of the logged-in user from zylker.com cookies. We also obtain the grant token and location from the redirect_uri of the authorization request. We pass these three values to the below integrateZohoCRM() function. This function takes care of creating a token for the connected Zoho CRM account and persisting it in the preferred datastore.


public static Boolean integrateZohoCRM(String location, String grant_token, String user_email) 
{
Boolean integrationStatus = Boolean.FALSE;
try {
Environment environment = DataCenter.get(location);
OAuthToken userToken = new OAuthToken.Builder()
                .clientID(OAuthClientDetails.CLIENT_ID)
                .clientSecret(OAuthClientDetails.CLIENT_SECRET)
                .grantToken(grant_token)
                .redirectURL(OAuthClientDetails.REDIRECT_URL)
                                 .userSignature(new UserSignature(user_email)) //email of the user who is trying to integrate with Zoho CRM          
                                 .build();
new Initializer.Builder().environment(environment).token(userToken).initialize(); 
integrationStatus = Boolean.TRUE;
    } catch (SDKException e) {
e.printStackTrace();
    } catch (Exception e) {
e.printStackTrace();
    }
return integrationStatus;
}

Refer here for the exact code section.

OAuthToken.Builder() creates a new instance of the builder for the OAuthToken class. It allows you to conveniently set up the necessary details for creating an OAuth token for authentication purposes. On passing the client ID, client secret, grant token, redirect URL, and user signature to the OAuthToken.Builder() method, we get the userToken object. One more important thing to note is that we have set the user signature as .userSignature(new UserSignature(user_email)) . This means that we are referring to the token uniquely by the email id of the logged-in Zylker user. The same signature should be used for any further operation to be done in Zoho CRM on behalf of this user.
Now that we have the OAuthToken object, we can send it to the Initializer class (as shown below) to create the refresh/access tokens and persist it.


 new Initializer.Builder().environment(environment).token(userToken).initialize(); 


As we haven't mentioned anything about where to do the persistence, by default the token details are persisted in a file named 'sdk_tokens.txt' using File Persistence. The content of the file would look like the following:


"id","user_name","client_id","client_secret","refresh_token","access_token","grant_token","expiry_time","redirect_url","api_domain" //Do not clear this default format, or else you will need  to generate a grant token again  in order to run the program.
"1","patricia@gmail.com","1000.xxxxx","xxxxxx","1000.xxxxxx.xxxx","1000.xxxxxxxxx.xxxxxxx","1000.xxxxxxxxx.xxxxxxx","1697370902510","https://www.zoho.com","https://www.zohoapis.com"



Apart from File Persistence, tokens can be persisted using Database persistence or Custom persistence.

Note

When Zoho introduces a new DC in future, it will be enough to update the project with the latest version of Zoho CRM Java SDK 5.0 and no further code change will be required. 

2. Fetching data from ZohoCRM

Once the integration is done, we can create OAuthToken with the user's email as UserSignature and call Zoho CRM Java SDK function. This will fetch the data specific to the user. The following fetchCRMData() function is a sample to fetch data from Zoho CRM.


public static void fetchCRMData(String email) throws Exception {
    OAuthToken userToken1 = new OAuthToken.Builder()
        .userSignature(new UserSignature(email))
        .build();
    new Initializer.Builder().token(userToken1).initialize();
    RecordOperations ro = new RecordOperations();
    ParameterMap paramInstance = new ParameterMap();
    List < String > fieldNames = new ArrayList < > (Arrays.asList("Company", "Email"));

    paramInstance.add(RecordOperations.GetRecordsParam.FIELDS, String.join(",", fieldNames));

    @SuppressWarnings("rawtypes")

    APIResponse response = ro.getRecords("Leads", paramInstance, null);

    .

    .

    .

}
 

Refer here for the exact code section.


In this example, we use the SDK's RecordOperations()  for retrieving records from the Leads module. This is done in the following steps:
  •  A new instance of RecordOperations is being created and assigned to the variable ro. This object handles operations related to records in Zoho CRM.  
  • ParameterMap instance is used to specify request parameters for the API calls. We can fetch the Company and the Email fields from the Leads module by passing them as the FIELDS parameter. 
  • We use the getRecords() method to make the API request via SDK, which fetches the respective CRM data.


We hope you found this post useful and interesting.  Stay tuned for more exciting posts.

Previous Kaizen Post : #107 Field Trackers in Zoho CRM

For more topics on Kaizen, please refer to our Kaizen collection here.







    Access your files securely from anywhere







                        Zoho Developer Community





                                              Use cases

                                              Make the most of Zoho Desk with the use cases.

                                               
                                                

                                              eBooks

                                              Download free eBooks and access a range of topics to get deeper insight on successfully using Zoho Desk.

                                               
                                                

                                              Videos

                                              Watch comprehensive videos on features and other important topics that will help you master Zoho Desk.

                                               
                                                

                                              Webinar

                                              Sign up for our webinars and learn the Zoho Desk basics, from customization to automation and more

                                               
                                                
                                              • Desk Community Learning Series


                                              • Meetups


                                              • Ask the Experts


                                              • Kbase


                                              • Resources


                                              • Glossary


                                              • Desk Marketplace


                                              • MVP Corner




                                                        Manage your brands on social media



                                                              Zoho TeamInbox Resources



                                                                  Zoho CRM Plus Resources

                                                                    Zoho Books Resources


                                                                      Zoho Subscriptions Resources

                                                                        Zoho Projects Resources


                                                                          Zoho Sprints Resources


                                                                            Qntrl Resources


                                                                              Zoho Creator Resources



                                                                                  Zoho CRM Resources

                                                                                  • CRM Community Learning Series

                                                                                    CRM Community Learning Series


                                                                                  • Kaizen

                                                                                    Kaizen

                                                                                  • Functions

                                                                                    Functions

                                                                                  • Meetups

                                                                                    Meetups

                                                                                  • Kbase

                                                                                    Kbase

                                                                                  • Resources

                                                                                    Resources

                                                                                  • Digest

                                                                                    Digest

                                                                                  • CRM Marketplace

                                                                                    CRM Marketplace

                                                                                  • MVP Corner

                                                                                    MVP Corner







                                                                                      Design. Discuss. Deliver.

                                                                                      Create visually engaging stories with Zoho Show.

                                                                                      Get Started Now


                                                                                        Zoho Show Resources


                                                                                          Zoho Writer Writer

                                                                                          Get Started. Write Away!

                                                                                          Writer is a powerful online word processor, designed for collaborative work.

                                                                                            Zoho CRM コンテンツ






                                                                                              Nederlandse Hulpbronnen


                                                                                                  ご検討中の方




                                                                                                        • Recent Topics

                                                                                                        • Zoho Inventory Feature Roadmap Visible To All

                                                                                                          Hello, please consider making your feature roadmap visible to us users so that we know what to expect in future. This may appease current users who are seeking clarification on feature implementation dates, so that they can make an informed decision whether
                                                                                                        • Data Template Amending

                                                                                                          Hi, is it possible to remove data templates once you have applied them in Workdrive? Also, once I have added a new field to a data template can I mass update multiple files who have already been allocated that template and amend just that one added
                                                                                                        • Upcoming Changes to LinkedIn Parsing in Resume Extractor

                                                                                                          Starting 31 July 2025, the Zoho Recruit Resume Extractor will no longer support direct parsing of candidate data from LinkedIn profiles. Why Is This Change Needed? In accordance with LinkedIn’s platform policies, extracting profile data through browser
                                                                                                        • Writer very buggy and glitchy after only a few minutes of use... oh my.

                                                                                                          I am finding Writer to be very buggy and glitchy while using it. I've tried it in Firefox, Chrome, Safari... all Mac. Complete words get deleted on backspace (probably a feature, but disconcerting and bad design, esp. if you just want to delete a couple
                                                                                                        • Important! ZipRecruiter Sponsored Posting Plan Changes in Zoho Recruit

                                                                                                          Greetings, We’re reaching out to inform you about an important upcoming change to the ZipRecruiter Sponsored job board integration within Zoho Recruit. What’s Changing? Starting June 1, 2025, Zoho Recruit will be updated with ZipRecruiter's latest pricing
                                                                                                        • How can I use the API to add a drop-shipping address to a sales order for one-time use?

                                                                                                          I need to be able to add a drop-shipping address for one-time use to a sales order via the API. Adding every such address to the contact (customer), then feeding the shippingaddress_id into the sales order, is not an acceptable approach; we have some
                                                                                                        • Mass Print Attachments from Selected Records in Custom Module

                                                                                                          Dear Zoho CRM Team, We’d like to request a feature enhancement regarding the handling of attachments. Use Case: We have a custom module that stores invoices uploaded by our affiliates. Currently, we need to open each record individually to print these
                                                                                                        • how to integrate zoho bigin to wordpress website ?

                                                                                                          hello , i want to integrate zoho bigin to wordpress webiste , can anyone help me with the tutorial ?
                                                                                                        • Surely it's time Inline editing from views

                                                                                                          I think the first request I found for in-line editing from grids was approximately 12 years ago - that post was locked because it was suggested Zoho sheetview solved the problem. However, it's now 2024, and in-line editing from grids is just a basic expectation.
                                                                                                        • How to work with getFieldNames formdata functions ,Any Examples

                                                                                                          I don't find any example showing usage of getFieldNames. Where do i find .is there any Help documents available
                                                                                                        • Issue with POST request creating Calls in CRM

                                                                                                          Hello, I am in the middle of integrating some 3rd party Call center API with Zoho CRM and going through our logs I see some discrepencies. We sometimes get an error: {"data":[{"code":"INVALID_DATA","details":{"api_name":"Call_Duration","json_path":"$.data[0].Call_Duration"},"message":"Please
                                                                                                        • Session "Ask Me Anything" Zoho France - Le 26 Juin 2025 14h à 17h (en Français

                                                                                                          Chers Utilisateurs, Vous cherchez à mieux comprendre Zoho CRM ou Zoho Desk ? Nos experts seront disponibles pour répondre à toutes vos questions lors de notre session Ask Me Anything. Rejoignez-nous ici pour en discuter en ligne. Pendant trois heures,
                                                                                                        • only lastname as index(?) field in custom module

                                                                                                          Hello, I have a small problem. I have created a custom module. The data records are only labeled with the last names. Also in the lookup etc.... It's stupid if you have different first names with the same surname. Then I only ever see the surname. In
                                                                                                        • Canvas View - Print

                                                                                                          What is the best way to accomplish a print to PDF of the canvas view?
                                                                                                        • Sesión "Ask me anything" Zoho en Español - 26 de junio de 2025, de 14:00 a 17:00 (en español)

                                                                                                          ¡Hola Comunidad! ¿Quieres entender mejor Zoho CRM o Zoho Desk? Nuestros expertos estarán disponibles para responder a todas tus preguntas durante nuestra sesión "Ask me anything". Puedes comentar este artículo y durante tres horas, nuestro equipo estará
                                                                                                        • How to read content out of File (Excel, Zoho Sheet, CSV) and iterate through rows

                                                                                                          Hello, I'd like to be able to iterate through all the rows in a CSV or Excel/Zoho Sheet file to perform actions on them. How is this possible in Flow? Thanks in advance! Best regards, Sven
                                                                                                        • Import CSV file into Zoho CRM using Zoho Flow?

                                                                                                          Is there a way to automate the import of contacts from Zoho Flow to Zoho CRM? I have a csv file on a remote server that I would like to pull off and import/update on a schedule.  I know you can do it with Zapier but I would like to stay within the Zoho
                                                                                                        • Domain Change from apkbark.com to apkbark.io – Do I Need to Setup Zoho Mail Again?

                                                                                                          I recently migrated my website from the old domain https://apkbark.com to the new domain https://apkbark.io. The Zoho Mail setup was previously configured and working perfectly on the old domain. Now I would like to know: Will my Zoho Mail setup automatically
                                                                                                        • TDS Filing

                                                                                                          Is there any option for automatic 26Q and 24Q filing in Zoho books. Even Tally has this option. Why don't Zoho has this ? Is there any customisation available for this ?
                                                                                                        • In the Blue Print Transition requirement received it will show 8 check field in pop up if they any one of this field then only move to next stage Ist quote

                                                                                                          In the Blue Print Transition requirement received it will show 8 check field in pop up if they any one of this field then only move to next stage Ist quote Pls help how i fix this
                                                                                                        • Sorry to inform you that currently we cannot access the subform fields through writer deluge (zoho.writer.mergeAndSend).

                                                                                                          This is the premium support answer from zoho. It means we cannot merge and send thru deluge related records (sub forms) items... Has anybody suffered from the same ordeal ? DO you have a workaround ? If not can you vote for this feature to be added to
                                                                                                        • Cross module filtering is now supported in CRM

                                                                                                          Editions: All DCs: All Release plan: This enhancement is being released in phases. It is now available in AU, JP, and CN DCs. Help resource: Advanced filters The Cross-module filtering enhancement is now available to all CRM accounts in the following
                                                                                                        • Quotes

                                                                                                          Has anyone figured out how to automatically upload a quote that was signed via Zoho Sign and insert it directly to that leads file and push it through the pipeline to proposal signed status?
                                                                                                        • I wan to schedule a meeting report From previous Thursday to this thursday of this week on Every 6 pm want to recive this report in zoho CRM

                                                                                                          I wan to schedule a meeting report From previous Thursday to this thursday of this week on Every 6 pm want to recive this report in zoho CRM. How I Can achive this in Zoho CRM.
                                                                                                        • Importing a contact with a linked product

                                                                                                          Hi, I'm trying to import my contacts from an excel spreadsheet and each of those contacts have fields that relate to products. Is there a way that I can import the contact with their linked product? Some of the contacts in my spreadsheet have multiple
                                                                                                        • CRM - Workflow Rules to be applied and work across modules

                                                                                                          Hello, It seems that you can't use workflow rules in CRM to work across modules, is this correct? I need a customer account status to be changed IF there have been no new deals or new quotes in the last 6 months. I can't see this is possible? I can create
                                                                                                        • Auto assign account owner

                                                                                                          hi, i need to auto assign leads and accounts to an owner by rules. i have created all the territories i need, and all territories have their owner. but when i want to auto assign a new or an existing account to a user by the rules of territories, only
                                                                                                        • How do I enter phone extensions?

                                                                                                          How do I add a phone extension correctly so that when I dial the main number it will pause and dial the extension of the contact I want to talk to Greg
                                                                                                        • How do you make tabs and place certain leads in them?

                                                                                                          I am trying to figure out how to make a tab for my Florida contacts, California contacts and New York contacts. I make a new view named "Florida Leads" but when I click on it, ALL of my leads pop up in the same view... Is there a way to move leads into different categories? Thanks, Wayne
                                                                                                        • Boolean Fields in Mail Merge Displaying as Checkmarks

                                                                                                          I'm really liking the new mail merge functionality. It's replaced the Zoho Sign extension for us. One problem I've seen is that boolean operators (i.e. Checkbox fields) in CRM merge as "True" or "False". This looks a little ugly in my final document —
                                                                                                        • 5名限定 課題解決型ワークショップイベント Zoho ワークアウト開催のお知らせ(7/24)

                                                                                                          ユーザーの皆さま、こんにちは。Zoho ユーザーコミュニティチームの藤澤です。 7月開催のZoho ワークアウトについてお知らせします。 2ヶ月ぶりに、渋谷にて「リアル開催」します! ▷▷詳細はこちら:https://www.zohomeetups.com/20250724Zoho ━━━━━━━━━━━━━━━━━━━━━━━━ Zoho ワークアウトとは? Zoho ユーザー同士で交流しながら、サービスに関する疑問や不明点の解消を目的とした「Zoho ワークアウト」を開催します。 Zoho サービスで完了させたい設定やカスタマイズ、環境の整備など……各自で決めた目標達成に向け、
                                                                                                        • Web to lead form not working

                                                                                                          I am starting to use this Zoho product (3 users for free) to see if it really does what it should prior to making a purchase decision. One of the important parts of the ZOHO CRM is the ability to create a web form that auto generates a lead. We have set
                                                                                                        • Is this a valid email from Zoho or a scam?

                                                                                                          Hi, I received an email advising me to update MX records for Zoho mail. Is it legitimate? Thanks, Nelson. Dear Admin, You may know that your domain (eg, yourcompany.com) has an MX record that points to an email server configured to process email for your domain. We have noticed that some of our customers have used Zoho IP address (instead of DNS server name) in their MX records to specify the mail server. This is NOT recommended practice. Vendors will sometimes change IP addresses for number of valid
                                                                                                        • Updating task using excel file

                                                                                                          Hi, Is there a way to update existing tasks using excel file import?  Thanks
                                                                                                        • Search on Postcode criteria not working properly

                                                                                                          Hi there, I used to be able to do an advanced candidate search on 'Postcode starts with' and then enter the first two letters of the UK postcode.  So if I used CH then it would bring back candidates in CH1, CH2, CH3 etc.  This seems to have changed in the last week so that it now only brings back postcodes that exactly match CH only.  I tend to use this search criteria extensively so need a fix for it asap please.
                                                                                                        • Quotes vs Invoices vs Sales Orders

                                                                                                          We have the need to create either quotes, invoices or sales orders for services we provide to clients for our sales team to present to them.  However, we are confused in the purpose of each and which we should choose.  Could someone explain the difference in them? Also, with these, we will have setup costs for our clients and then fixed monthly costs.  For instance, we have services that are one-time services at $997 and then we have others that are monthly only ($250 per month).  In addition, we
                                                                                                        • Tip 14: How to iterate a set of Deluge code a specific number of times.

                                                                                                          Hello folks, As you might already know, recursive functions are used to perform a particular action a specific number of times. We had explained this in detail in our Tip #2. Similarly, there is another way in which you can iterate a set of Deluge code 'n' number of times. All you need to do is to create a List and use the For each index task to iterate it for a specific number of times.    Here are a few use cases where this would be useful to you:  To create 'n' number of duplicate records for
                                                                                                        • Is it possible to register webhooks in Zoho CRM using API?

                                                                                                          Hello, I am trying to register a webhook in Zoho CRM programmatically (using the API). Specifically, I want to register a webhook that is fired when new Contacts are created in the CRM. I was able to setup a webhook using the UI, by creating a rule that
                                                                                                        • Can't set conditional layout rule on lookup field in Zoho CRM

                                                                                                          Namaskaram Zoho CRM team,      Usually any fields of module except mandatory fields can be hide using conditional layout rules.  But that can't be set on lookup fields event that is not a mandatory fields.  Many users are in need of that.   Crafted with
                                                                                                        • Restrict Zoho One Account Notifications to Admins

                                                                                                          Hi Zoho One Team, I hope you're doing well. We recently noticed that end users are receiving administrative pop-ups in Zoho One, such as the DKIM configuration notice (screenshot attached). This type of notification is only relevant to administrators
                                                                                                        • Next Page