How to Use Zoho CRM V2 API

Posted By : Rohan Dodeja | 18-Mar-2018

Steps to use zoho crm :-

1) creating zoho client id and client secret id.

2) creating short-lived grant token using client id and secret key

3) creating access and refresh token by using grnat token.

4) then use refresh token to generate access token as access token will expire in every 1 hour so use refresh token every time to generate access token.

5) now use generated access token to hit other api's like push and get data from zoho or upload or view attachements from zoho.

 

Step 1:-

To generate client id and client secret key.

a) visit URL accounts.zoho.com/developerconsole

b) follow on-screen steps to generate client id and secret id

 

Step 2:-

use following sample URL to generate grant token:-

	https://accounts.zoho.com/oauth/v2/auth?scope=ZohoCRM.modules.all&client_id=1000.xxxxxxxxxxx&response_type=code&access_type=offline&redirect_uri=https://www.getpostman.com/oauth2/callback

API response:-

	https://app.getpostman.com/oauth2/callback?code=1000.68d78ede5f1934cefc7af9281a289b51.907604634d145ea37a7847b5f8651e80&location=us&accounts-server=https%3A%2F%2Faccounts.zoho.com

Note:- I used access_type = offline as I need to generate refresh token and if I use online than it will not generate refresh token but only access token which will be destroyed after an hour but refresh token never expire so you can use access refresh token to regenerate access token.

Step 3:-

use the following URL to generate access and refresh token:-

	https://app.getpostman.com/oauth2/callback?code=1000.xxxxxxxxxxx.xxxxxx&location=us&accounts-server=https%3A%2F%2Faccounts.zoho.com

API response:-

	{
    "access_token": "1000.5bxxxxxxxx77544fc89.329xxxxxxx553127937a2eabf7d59e09",
    "refresh_token": "1000.xxxxxxxx.xxxxxxxx",
    "expires_in_sec": 3600,
    "api_domain": "https://www.zohoapis.com",
    "token_type": "Bearer",
    "expires_in": 3600000
	}

Step 4:-

now before hitting any API using the post URL to generate access token:-

	https://accounts.zoho.com/oauth/v2/token?refresh_token={refresh_token}&client_id={client_id}&client_secret={client_secret}&grant_type=refresh_token

API response:-

	{
	"access_token": "{new_access_token}",
	"expires_in_sec": 3600,
	"api_domain": "https://www.zohoapis.com",
	"token_type": "Bearer",
	"expires_in": 3600000
	}

Step 5:

now you can hit API like pushing data to predefined contacts module using following post URL with request body:-

	https://www.zohoapis.com/crm/v2/{module_api_name}/upsert
	{
    "data": [
       {
            "Last_Name": "Daly",
            "First_Name": "Paul",
            "Email": "[email protected]"
        }
    ]
	}

API response:-

	{
    "data": [
       {
            "message": "record updated",
            "details": {
                "created_by": {
                    "id": "4108880000086001",
                    "name": "Patricia Boyle"
                },
                "id": "410888000000478065",
                "modified_by": {
                    "id": "4108880000086001",
                    "name": "Patricia Boyle"
                },
                "modified_time": "2016-04-28T17:59:21+05:30",
                "created_time": "2016-04-28T17:59:21+05:30"
            },
            "status": "success",
            "duplicate_field": "Email",
            "action": "update",
            "code": "SUCCESS"
        }
    ]
	}

About Author

Author Image
Rohan Dodeja

Rohan is a bright web app Lead developer and have experience on Java, J2EE, REDIS, SQL. His hobbies are gaming and Travelling.

Request for Proposal

Name is required

Comment is required

Sending message..