Zoho CRM custom function API request syntax - calling from Google Apps Script with custom arguments in Body/Payload

Zoho CRM custom function API request syntax - calling from Google Apps Script with custom arguments in Body/Payload

Putting this down here as it's taken me ages to figure out - hopefully can save time for somebody else.

Objective: call custom Zoho CRM function from Google Apps script, with custom arguments in the Body/Payload

Sample Google Apps script code
function zTestAPIJSONPayload(){
  
  // Make a POST request with a JSON payload.
  
  var formData = {"input1":"goes here", "input2":"56"};
  var options =
      {
        "method" : "post",
        "contentType" : "application/json",
        // this also works fine as an alternative format        "payload" : '{ "input1": "hereis the first input", "input2": " here is the second input"}'
        "payload" : JSON.stringify(formData) //doing this JSON.stringify conversion is ESSENTIAL or the Zoho CRM function doesn't recognise the input as JSON
      };
  try{
    
    var response = UrlFetchApp.fetch('https://www.zohoapis.com/crm/v2/functions/[FUNCTION NAME HERE]/actions/execute?auth_type=apikey&zapikey=1003[KEY HERE]', options);
    
    contentText = response.getContentText();
    console.log("contentText: " + contentText);  
  }
  catch(e)
  {
    console.log("Error is " + e);
  }
}

Sample Zoho custom function
body = crmAPIRequest.get("body");
i1 = body.get("input1");
i2 = body.get("input2");
sendmail
[
from :zoho.adminuserid
to :zoho.adminuserid
subject :"API function call crmAPIRequest"
message :"crmAPIRequest is " + crmAPIRequest
]
return "i1 = " + i1 + " and i2 = " + i2;

Things to ensure
  • The single argument for the custom function needs to be crmAPIrequest, type = string, like this:



CR

    Access your files securely from anywhere







                            Zoho Developer Community




                                                  • Desk Community Learning Series


                                                  • Digest


                                                  • Functions


                                                  • Meetups


                                                  • Kbase


                                                  • Resources


                                                  • Glossary


                                                  • Desk Marketplace


                                                  • MVP Corner


                                                  • Word of the Day


                                                  • Ask the Experts



                                                            • Sticky Posts

                                                            • Kaizen #226: Using ZRC in Client Script

                                                              Hello everyone! Welcome to another week of Kaizen. In today's post, lets see what is ZRC (Zoho Request Client) and how we can use ZRC methods in Client Script to get inputs from a Salesperson and update the Lead status with a single button click. In this
                                                            • Kaizen #222 - Client Script Support for Notes Related List

                                                              Hello everyone! Welcome to another week of Kaizen. The final Kaizen post of the year 2025 is here! With the new Client Script support for the Notes Related List, you can validate, enrich, and manage notes across modules. In this post, we’ll explore how
                                                            • Kaizen #217 - Actions APIs : Tasks

                                                              Welcome to another week of Kaizen! In last week's post we discussed Email Notifications APIs which act as the link between your Workflow automations and you. We have discussed how Zylker Cloud Services uses Email Notifications API in their custom dashboard.
                                                            • Kaizen #216 - Actions APIs : Email Notifications

                                                              Welcome to another week of Kaizen! For the last three weeks, we have been discussing Zylker's workflows. We successfully updated a dormant workflow, built a new one from the ground up and more. But our work is not finished—these automated processes are
                                                            • Kaizen #152 - Client Script Support for the new Canvas Record Forms

                                                              Hello everyone! Have you ever wanted to trigger actions on click of a canvas button, icon, or text mandatory forms in Create/Edit and Clone Pages? Have you ever wanted to control how elements behave on the new Canvas Record Forms? This can be achieved


                                                            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

                                                                                              Get Started. Write Away!

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

                                                                                                Zoho CRM コンテンツ



                                                                                                  Nederlandse Hulpbronnen


                                                                                                      ご検討中の方