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 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
- 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 ];
- 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
- ];
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 ];
- 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
- 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
info m_Response.get("item").toMap().get("item_id"); // yields: 123456789012345678
- 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"}
- 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"}
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);
- 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:
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
- // 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
- 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
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
- 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 ];
- v_DataEndpoint = "https://books.zoho.com/api/v3/contacts?organization_id=123456789";
- r_Response = invokeUrl
- [
- url :v_DataEndpoint
- type :GET
- connection: myConnector
- ];
v_DataEndpoint = "https://books.zoho.eu/api/v3/contacts?organization_id=123456789"; r_Response = invokeurl [ url :v_DataEndpoint type :GET connection: myConnector ];
- v_DataEndpoint = "https://books.zoho.eu/api/v3/contacts?organization_id=123456789";
- r_Response = invokeUrl
- [
- url :v_DataEndpoint
- type :GET
- connection: myConnector
- ];