Kaizen 202 - Answering Your Questions | Testing and Using REST APIs in Widgets

Kaizen 202 - Answering Your Questions | Testing and Using REST APIs in Widgets



Hello Developers!

Welcome back to a fresh week of Kaizen! 

Thank you for your active participation in sharing feedback and queries for the 200th milestone. This week, we will look at the following queries related to widget:
  • Widget Testing 
  • Using REST API in Canvas Widgets: Make HTTP calls in widgets (e.g., to external tax or product APIs)
Here are the queries that we have already answered for you from this milestone:
  1. Kaizen #200 - Answering Your Questions | Token generation using the Python SDK
  2. Kaizen #201 - Answering Your Questions | Webhooks, Functions, and Schedules

Widget Testing

One of the queries we received was simply stated
Quote
Widget Testing
 without any specific context. Since the user has not provided detailed input, we are assuming this is about how to test a widget during development.

You can test your Zoho CRM widget locally using the Zoho CLI. Run the following command from the root directory of your widget project:

zet run

This launches the widget on a local server where you can validate the UI and functionality before pushing it live.


Since the localhost connection opens in a new tab and is not private, you will need to manually authorize it. 

Click Advanced, then choose Proceed to 127.0.0.1 (unsafe) to continue. 

Notes
Note

If your widget needs to access data from your Zoho CRM organization, such as fetching or updating records, it must be deployed within a Zoho CRM iframe. To do this, you should upload the widget through the Zoho CRM Widgets setup page.

We recommend using the sandbox environment in such cases before deploying the widget to your production environment.

Making HTTP Calls from Widget

Following is a query we received from a user:
Quote
Using REST API in Canvas Widgets: Make HTTP calls in widgets (e.g., to external tax or product APIs)
Yes. You can make HTTP requests to external services from any type of Zoho CRM widget using the ZOHO.CRM.HTTP object from the Widget JS SDK.

Canvas Widget - What's Supported? 

Though full widget support within Canvas is on our roadmap, currently, you can invoke widgets from a Canvas view using Client Script. This lets you render widgets inside fly-outs or pop-ups. Here is a quick start guide on how you can achieve it:

Create a Widget

1. Create a widget project and code your logic using Zoho CLI as explained in our widget help page.

2. In Zoho CRM Developer Hub, create a new widget and set the type as Button.



Create a Client Script

3. Navigate to Client Scripts in Developer Hub and click New Script.

4. You can create your script either in the Modules or Commands category based on your use case. 

For assistance, refer to the step-by-step guide on Creating Client Script and Commands.



In the Category Details section, ensure to select Canvas as the page type. Canvas views are supported in the following page contexts: List, Detail, Create, and Clone. 

Choose the one that aligns with where your widget needs to appear.


5. Here is the sample script to render widget in a pop-up

ZDK.Client.openPopup({
api_name: 'Canvas_Widget',
type: 'widget',
animation_type: 4, 
height: '450px',
width: '450px',
},
{
data: 'sample data to be passed to "PageLoad" event of widget'
}); 

Here is the sample script to render widget in a fly-out

ZDK.Client.createFlyout('myFlyout', { 
animation_type: 4, 
height: '600px', 
width: '500px'
}
);
ZDK.Client.getFlyout('myFlyout').open({ api_name: 'Canvas_Widget', type: 'widget' });

For detailed guidance, check out our Client API documentation on Pop-up and Fly-out.

You can also check out the Kaizen #99 on Rendering Widgets using Client Script for a detailed guide based on a real-time use case. 

Using REST APIs from External Applications

The ZOHO.CRM.HTTP object enables you to make secure API calls directly from the Zoho CRM widget. It acts as a proxy, routing requests through Zoho servers, which eliminates the need for external applications to support CORS.

While this SDK is primarily used for integrating third-party services, it also supports Zoho CRM API calls. This provides you with greater flexibility to:
  • Customize header and parameter structures
  • Maintain a consistent calling pattern for both internal and external APIs within the widget.
Here is a basic syntax of the SDK:

ZOHO.CRM.HTTP.<method>({
  url: "<request-url>",
  headers: {
       // Request headers as Key-value pairs
    "Authorization": "Bearer <token>" // example
  },
  params: {
    // Request params as Key-value pairs

   "ids": "1234567890" // example
  },
  body: "<stringified JSON>", // Required for POST, PUT and PATCH
})
.then(function(response) {
  console.log("Response:", response);
});

Supported Methods
  • ZOHO.CRM.HTTP.get({ ... })
  • ZOHO.CRM.HTTP.post({ ... })
  • ZOHO.CRM.HTTP.put({ ... })
  • ZOHO.CRM.HTTP.patch({ ... })
  • ZOHO.CRM.HTTP.delete({ ... })
For more detail check out the HTTP method section of JS SDK help page.

Samples using Zoho CRM Contact Roles API

Let us explore a complete CRUD (Create, Read, Update, Delete) example using Zoho CRM’s Contact Roles API.

These structures have to be used within the JS function where you are executing your code logic. 

POST Contact Roles


// Prepare the API request
        var request = {
          url: "https://www.zohoapis.com/crm/v8/Contacts/roles",
          headers: {
            Authorization: "Zoho-oauthtoken 1000.XXXXXXXXXXXXXXXXXXX265bcf20e4"
          },
          body: {
            "contact_roles": [
              {
                "name": "Sales Lead",
                "sequence_number": 1
              }
            ]
          }
        };
         // Make API call 
        ZOHO.CRM.HTTP.post(request).then(function(data) {
          console.log(data);
 })

GET Contact Roles


// Prepare the API request
var request = {
          url: "https://www.zohoapis.com/crm/v8/Contacts/roles",
          headers: {
            Authorization: "Zoho-oauthtoken 1000.XXXXXXXXXXXXXXXXXXX265bcf20e4"
          }
        };
        // Make API call 
        ZOHO.CRM.HTTP.get(request)
          .then(function(response) {
 console.log(response);
})

UPDATE Contact Roles

// Prepare the API request
        var request = {
          headers: {
            Authorization: "Zoho-oauthtoken 1000.XXXXXXXXXXXXXXXXXXX265bcf20e4"
          },
          body: {
            "contact_roles": [
              {
                "name": "Evaluator",
                "id": "5545974000000006871"
              }
            ]
          }
        };
        // Make API call 
        ZOHO.CRM.HTTP.put(request).then(function(data) {
          console.log(data);
 })

DELETE Contact Roles


// Prepare the API request
        var request = {
          params: {
            ids: "5545974000002617002"
          },
          headers: {
            Authorization: "Zoho-oauthtoken 1000.XXXXXXXXXXXXXXXXXXX265bcf20e4"
          }
        };
        // Make API call 
        ZOHO.CRM.HTTP.delete(request).then(function(data) {
          console.log(data);
 })

We hope you found this post useful. 

Let us know if you have any questions in the comments or drop us an email at support@zohocrm.com.

Cheers!

------------------------------------------------------------------------------------------------------------------------

Related Reading


------------------------------------------------------------------------------------------------------------------------
    • Sticky Posts

    • Kaizen #197: Frequently Asked Questions on GraphQL APIs

      🎊 Nearing 200th Kaizen Post – We want to hear from you! Do you have any questions, suggestions, or topics you would like us to cover in future posts? Your insights and suggestions help us shape future content and make this series better for everyone.
    • Kaizen #198: Using Client Script for Custom Validation in Blueprint

      Nearing 200th Kaizen Post – 1 More to the Big Two-Oh-Oh! Do you have any questions, suggestions, or topics you would like us to cover in future posts? Your insights and suggestions help us shape future content and make this series better for everyone.
    • Celebrating 200 posts of Kaizen! Share your ideas for the milestone post

      Hello Developers, We launched the Kaizen series in 2019 to share helpful content to support your Zoho CRM development journey. Staying true to its spirit—Kaizen Series: Continuous Improvement for Developer Experience—we've shared everything from FAQs
    • Kaizen #193: Creating different fields in Zoho CRM through API

      🎊 Nearing 200th Kaizen Post – We want to hear from you! Do you have any questions, suggestions, or topics you would like us to cover in future posts? Your insights and suggestions help us shape future content and make this series better for everyone.
    • Client Script | Update - Introducing Commands in Client Script!

      Have you ever wished you could trigger Client Script from contexts other than just the supported pages and events? Have you ever wanted to leverage the advantage of Client Script at your finger tip? Discover the power of Client Script - Commands! Commands
    • Recent Topics

    • Set Conditional and Dependent Rules for Issues in Zoho Projects

      An Issue Layout is a customizable form to add and update information about a specific issue. The fields in the issue layout can be changed dynamically based on user requirement using the issue layout rules. Consider a scenario where an electrical fluctuation
    • Accounting on the Go Series-56: e-Way Bill Module in the Mobile App – A Handy Solution for Indian Businesses

      Hello everyone, Managing e-Way bills just got more convenient with the Zoho Books mobile app! For businesses operating under the GST regime, e-Way bills are essential for tracking the movement of goods. Previously, you had to log in to the web app to
    • Copying records from a Custom Module into Deals

      Hello, I recently created a custom module to handle a particular type of order/transaction in our business. Having got this up and running I've realised that it would be much better to use the Deals module with a different layout instead. We've entered
    • Creator App on Mobile - Workflow "On Create / Edit - On Load" not triggered ?

      Hi Everyone, I built an application to track assets, which is used both at the office (desktop) an in the field by technicians (mobile app). In the field, technicians open an existing form and add rows to a subform at some point. One field they have to
    • HOW TO VIEW INDIVIDUAL COST OF NEWLY PURCHASED GOODS AFTER ALLOCATING LANDED COSTS

      Hello, I have been able to allocate landed costs to the purchase cost of the new products. however, what i need to see now is the actual cost price (original cost plus landed cost), of only my newly purchased products to enable me set a selling price
    • Custom Function to get custom field of lookup type in Books

      Hi, Here's the situation. In Purchase Order, there is a custom field (lookup) to SO. The requirement is to update to the related SO if PO get updated Right now facing challenge to get the id of custom field (lookup) in PO. Please find below the sample
    • Custom From Address is now Organizational Email

      We're introducing a small yet meaningful change in Zoho Recruit, one that sets the foundation for bigger improvements coming your way. What’s changed? We’ve renamed the Custom From Address to Organizational Email. The new name was chosen to better reflect
    • What's New in Zoho Billing Q2 2025

      Hello everyone, We are excited to share the latest set of updates and enhancements made to Zoho Billing in Q2 2025, ranging from image custom fields to support for new languages. Keep reading to learn more. Upload Images From Your Desktop to Email Notifications
    • Map dependency on Multiselect picklist

      I need help in Zoho CRM. I have 2 multi-select picklists. For example, Picklist A has country names. Picklist B has state names. Now I want to show states on the basis of the selected country from Picklist A. Both are multi-select fields, so the standard
    • Tip of the Week #63 – Keep personal emails out of team view.

      Shared inboxes are great for teamwork—they let everyone stay on the same page, respond faster, and avoid duplicate replies. But not every message needs to be shared with the entire team. Think about those one-on-one chats with a manager, a quick internal
    • Episode III : Powering Automation: Custom Functions in Action

      Hello Everyone, In our previous episodes, we explored custom functions and the Deluge programming language. If you’ve been wondering why the Episode series have been quiet, here’s the reveal! On our community, we've been showcasing custom functions integrated
    • Narrative 2 - Understanding Organizational Departments

      Behind the scenes of a successful ticketing system - BTS Series Narrative 2 - Understanding Organizational Departments A ticketing system's departments are essential because they provide an organized and practical framework for handling and addressing
    • Zoho Projects Plus for the healthcare industry

      The global healthcare industry is complex and diverse; from patient record maintenance, healthcare supply chain, to manufacturing complex medical equipment, the industry functions on many layers. Managing all these layers requires tested out techniques
    • Missing Outlook calendar option in Calendar

      Hi all I don't have an Outlook Calendar option in the Settings > Synchronise settings of Calendar. Any ideas why not?
    • Zoho Meeting Android app update: Breakout rooms, noise cancellation

      Hello everyone! In the latest version(v2.6.1) of the Zoho Meeting app update, we have brought in support for the following features: 1. Join Breakout rooms. 2. Noise cancellation Join Breakout rooms. Breakout Rooms are virtual rooms created within a meeting
    • Whats App Automation

      It would be nice to be able to send out an automated whats app message template on moving stages or creation of a ticket (same as you can do for automated emails). Currently only automated emails can be sent. Also, if whats app could be used more effectively
    • Zoho Projects Android app update: Enhanced Documents module within the projects.

      Hello everyone! In the latest Android version(v3.9.35) of the Zoho Projects app update, we have enhanced the documents module within the projects. Now, you can view all the attachments that you have added across the project in tasks, bugs, comments, etc,
    • Lead Source Disappears

      When adding a new lead and saving the page, the page refreshes itself and the lead source field becomes blank. We set the "Lead source" as a required field to see if it would help, but the problem persists and we always have to re-enter the lead sou
    • Inquiry Regarding Monitoring ZOHO CRM API Credit Usage

      Hello ZOHO Community, I hope this message finds you well. I have a question regarding monitoring the usage and remaining credits of the ZOHO CRM API. I recently discovered that within ZOHO CRM, by navigating to Settings ⇒ Developer Hub ⇒ APIs & SDKs,
    • Payment Gateways - A unified hub to manage all your payment integrations in Zoho Creator

      Hello everyone, We're thrilled to announce that we've completely reimagined the way payment gateways are handled in Creator. The result is a centralized Payment Gateways section that provides a clean, user-friendly interface to configure and manage all
    • Community Digest Julio 2025 - Todas las novedades en Español Zoho Community

      ¡Hola, Español Zoho Community! Ha pasado un tiempo desde el último Digest pero, ¡ya estamos de vuelta con las novedades más relevantes en las aplicaciones de Zoho y su universo! Si no te quieres perder ninguna de las novedades que vamos publicando, te
    • Tip #35- How to use Notifications in Zoho Assist to stay on top of session activities- 'Insider Insights'

      Hello Zoho Assist Community! This week, we’re exploring Zoho Assist’s built-in notification system for improved visibility and accountability. Keeping track of session activity is crucial, especially when you're managing multiple remote devices and technicians.
    • Assistance with Exporting Specific Data from Zoho CRM

      Hi, Could you please guide me on how to export specific information, such as the model number and serial number, from the Accounts module in Zoho CRM? Thank you in advance for your assistance.
    • Coming Soon in Zoho Invoice: Send Invoices Instantly via WhatsApp

      We're working on bringing a new level of convenience to your invoicing experience. Introducing a much-requested feature in Zoho Invoice: You can now share invoices directly to your customers via WhatsApp! With this new option, you can: Share invoices
    • field update from the value of another field

      Hello, I need to do a field update from the value of another field, but i don´t know how can i do it. In the mass update option it is not possible... I need to put the last name value form the leads module to other custom field that i have created. thanks for your help
    • What is a realistic turnaround time for account review for ZeptoMail?

      On signing up it said 2-3 business days. I am on business-day 6 and have had zero contact of any kind. No follow-up questions, no approval or decline. Attempts to "leave a message" or use the "Contact Us" form have just vanished without a trace. It still
    • Playback and Management Enhancements for Zoho Quartz Recordings

      Hello Zoho Team, We hope you're all doing well. We would like to submit a feature request related to Zoho Quartz, the tool used to record and share browser sessions with Zoho Support. 🎯 Current Functionality As of now, Zoho Quartz allows users to record
    • Is there any way to prevent the row cloning feature(on edit page)

      My initial requirement is to prevent some users from adding new rows in the subform. For that, I have implemented the client script, and the script is working fine. But users are able to clone the row and make changes. For that, I was unable to find any
    • Using Another Field Value for Workflow Field Update

      I'm trying to setup a Workflow with a "Field Update" action on the Lead module, but I would like the new value to actually be taken from a DIFFERENT Field's on the Lead record (vs just defining some static value..) Is this possible? Could I simply use
    • How Do I Change Business Location

      Ive just shifted my business to a new country and would like to update my address and Business location in the "Organisation Profile" page but it is locked in the previous country. How do I unlock it / change it? Thanks
    • Verify details pop-up windows

      Hi, Is it possible to turn-off the anoying "Verify details" window that ask for closing date, "Reason for Lost" or other concepts. If I would like the user to enter such data, I will implement a rule .... How can I turn-off such pop-up? it's not necessary
    • Monthly overtime wrong after adding/changing attendance time for past month

      Hi there, as I understand it, the montly overtime overview under attendance is calculated at the end of each month. If someone was not able to enter his attendance in time but entered it in the new month, this time will not be considered in the overview.
    • As a security measure, you need to link your phone number with this account and verify it to proceed further.

      I want to disable this feature as my one staff travels with different phone numbers so it is hard to verify by phone. How do I do that?
    • Asset Tracking

      I am looking to create custom modules to track customer assets. We install serialized and non-serialized equipment into customers vehicles. So we will have vehicles belonging to the customer then equipment that will belong to a vehicle (if installed)
    • Will zoho thrive be integrated with Zoho Books?

      title
    • 【参加無料】8月8日(金) 福岡 ユーザ交流会 参加登録 受付開始!

      ユーザーの皆さま、こんにちは。コミュニティチームの藤澤です。 8月8日(金)に1年ぶりに、福岡でZoho ユーザー交流会を開催します! ユーザー事例セッションでは、CreativeStudio樂合同会社の前田 美知太郎さまが、労働時間を削減したZoho活用のリアルな工夫を語ります。 Zoho社員セッションでは、データ収集から自動処理まで一気に効率化できるZoho Formsの最新活用アイディアをお届けします。 ▷▷詳細はこちら:https://www.zohomeetups.com/Fukuoka2025#/?affl=fuk2508forumpost
    • Unusable due to "server" issues but there's nothing on Zoho or Down Detector saying there's an outage

      I just started the Zoho trial and I cannot do anything because no apps or even the "contact support" will actually load. I tried to create a project but it keeps giving me the error "server is unable to process your request at this time". I tried to load
    • Issue After Updating to Zoho Desk Android SDK v4.5.0 – Authentication Fails (Status Code 204)

      Hi Zoho Support Team, I was previously using the Zoho Desk Android SDK with the following dependency: implementation 'com.zoho.desk:asapsdk:3.0_BETA_17' Everything was working as expected — including user authentication, the tickets section, and the
    • add another department to helpcenter

      After activating multi-brand, how to add another department to help center? For example department A has associated with help center 1. We have another department B and would like user to be able to submit ticket to department B via help center 1, how
    • Task and Milestones - Dependency feature needed

      I'm sure we're not the first to bring this up. We've been using zoho project for a while. Every project manager knows that to manage a successful project you need option to stack tasks and milestones and be able to create dependencies between tasks and milestones. I think you get the idea... Can you let us know if this feature is in the making or not? any chance we'll see this in future releases? If you need customer feedback about this feature or other enhancements, we'll be happy to test new products
    • Next Page