Zoho CRM/Creator - Common Errors & Gotchas

What?
A quick article on how to debug some errors in Zoho.

Why?
I wanted a general note to list certain errors that we get when we do certain things in Zoho but didn't want to write a separate page for each minor issue.

How?
So I'm going to try and list solutions to minor errors we run into.

Problem: Zoho OAuth Connection: ERROR_invalid_operation_type
Sounds rather straightforward, Login to ZohoCRM as Administrator > Setup > Developer Space > Connections > Add Connection > Give it a name and then select Scopes > and get
ERROR_invalid_operation_type
Solution: Remove some scopes and test.
The likely ones you want are:
ZohoCRM.modules.ALL
ZohoCRM.settings.ALL
ZohoCRM.users.ALL

or to be safe

ZohoCRM.modules.ALL
ZohoCRM.settings.READ
ZohoCRM.users.READ

Problem: Code 37: The HTTP method PUT is not allowed for the requested resource
This was an issue where I was trying to push a Zoho Creator record into Zoho Inventory via an invokeURL with API v2 rather than a connector. If you use POST then this adds/creates a record and if it already exists you will get a {"code":1001,"message":"Item \"...\" already exists."}. Documentation advises that the payload is empty which is not true in my case. This is my invokeUrl:
v_DataEndpoint = "https://inventory.zoho.com/api/v1/items?organization_id=123456789";
r_Response = invokeurl
[
	url :v_DataEndpoint
	type :POST
	parameters:m_CreateRecord
	headers:m_Header
];
Solution: My endpoint was the same as a create/add record when it should be suffixed with the ID of the item to update:
v_DataEndpoint = "https://inventory.zoho.com/api/v1/items/{item_id}?organization_id=123456789";
r_Response = invokeurl
[
	url :v_DataEndpoint
	type :PUT
	parameters:m_CreateRecord
	headers:m_Header
];

Problem: Value is empty and 'get' function cannot be applied
Following a post similar to the above example by InvokeURL and then getting a JSON response back, the response does not seem to be read as a map:
r_Response = invokeurl
[
	url :v_DataEndpoint
	type :POST
	parameters:m_CreateRecord
	headers:m_Header
];
info r_Response;
// yields: { "code": 0, "message": "The item has been added.", "item": { "item_id": "2124100000000081031", .... }}

info r_Response.get("item");
// yields: "item_id": "2124100000000081031", .... 

info r_Response.get("item").get("item_id");
// yields: Value is empty and 'get' function cannot be applied
Solution: I have to convert the node into a map:
info m_Response.get("item").toMap().get("item_id");
// yields: 123456789012345678

Problem: Inserting a date time string into a date time field in Deluge
So annoying but sometimes you want to insert a date/time value into a date/time field and you get the error:
v_MyDateTimeString = zoho.currenttime.toString("yyyy-MM-dd'T'HH:mm:ssZ");
// value is "2020-02-10T11:49:12+0100"

// yields
{"code":"INVALID_DATA","details":{"expected_data_type":"datetime","api_name":"Updated_DateTime"},"message":"invalid data","status":"error"}
Solution: The above ALMOST works for API and Deluge Shortcode, but we're missing the colon in the TimeZone value:
v_TimeZone = zoho.currentdate.toString("Z");
v_TimeZoneStr = v_TimeZone.substring(0,3) + ":" + v_TimeZone.substring(3);
v_InsertDateTime = zoho.currenttime.toString("yyyy-MM-dd'T'HH:mm:ss") + v_TimeZoneStr;
// value is "2020-02-10T11:49:12+01:00"

// OR in some cases
v_TimeZone = "Europe/London";
v_InsertDateTime = zoho.currenttime.toString("yyyy-MM-dd HH:mm:ss",v_TimeZone);

Problem: ERROR_Invalid_Redirect_URI
Can happen when trying to setup an OAuth connection:
ERROR_Invalid_Redirect_URI
Solution: The redirect URI in your app does not match the redirect used in the authorization request. They need to match in both irrespective of the value. Consider trying to get authorized and checking the Redirect URI passed in the URL and then updating your app with the same value, such as:
// for Books OAuth 2.0 Connection - Custom Service - on account server EU
https://dre.zoho.eu/delugeauth/callback

// for Books OAuth 2.0 Connection - Custom Service - on account server COM
https://dre.zoho.com/delugeauth/callback

// for Inventory OAuth 2.0 Connection - Custom Service - on account server COM
https://deluge.zoho.com/delugeauth/callback

Problem: Split a string with the escape character/backslash character
Trying to split a string into a list by the backslash character:
v_File = "C:\Documents\My_File.txt";
// want to extract My_File.txt

l_FileParts = v_File.toList("\\");
info l_FileParts.get(l_FileParts.size() - 1);
// yields C:\Documents\My_File.txt
Solution: Replace the backslash first with another character:
v_File = "C:\Documents\My_File.txt";
v_FileString = v_File.toString().replaceAll("\\", "|");
// yields C:|Documents|My_File.txt

l_FileParts = v_FileString.toList("|");
v_ThisPart = l_FileParts.get(l_FileParts.size() - 1);
// yields My_File.txt

Problem: Code 57: You are not authorized to perform this operation
This is a quick issue to resolve as it may be incorrect scopes specified but in my case is more than often the wrong accounts server:
v_DataEndpoint = "https://books.zoho.com/api/v3/contacts?organization_id=123456789";
r_Response = invokeurl
[
	url :v_DataEndpoint
	type :GET
	connection: myConnector
];
Solution: My endpoint was specifying COM instead of EU as per the client's data center:
v_DataEndpoint = "https://books.zoho.eu/api/v3/contacts?organization_id=123456789";
r_Response = invokeurl
[
	url :v_DataEndpoint
	type :GET
	connection: myConnector
];

Related Articles

Joes Revolver Map

Accreditation

Badge - Certified Zoho Creator Associate
Badge - Certified Zoho Creator Associate

Donate & Support

If you like my content, and would like to support this sharing site, feel free to donate using a method below:

Paypal:
Donate to Joel Lipman via PayPal

Bitcoin:
Donate to Joel Lipman with Bitcoin - Valid till 8 May 2022 3QnhmaBX7LQSRsC9hh6Je9rGQKEGNQNfPb
© 2021 Joel Lipman .com. All Rights Reserved.