Custom JS API v2
Table of Contents
Overview
Custom APIs configured in Creator can be invoked from within a widget. This allows you to perform CRUD operations and custom functionalities in your applications.
Before continuing, make sure to check out everything you need to know about custom APIs.
Request Details
Syntax
Use the below logic in the widget's JS file to invoke custom APIs as shown below.
ZOHO.CREATOR.DATA.invokeCustomApi(config).then(function (response) {console.log(response)
});
Syntax Details
The syntax holds:
- <config> (object) - The configuration required to call a custom API. This configuration includes the following parameters.
Name | Type | Description |
api_name | string | Link name of the custom API that is being invoked. Retrieve the API link name using the endpoint URL of the custom API: https://www.zohoapis.com/creator/custom/<workspace_name>/<api_name> |
workspace_name (Optional) | string | Link name of the workspace in which this custom API will perform actions. Retrieve the workspace name using the endpoint URL of the custom API: https://www.zohoapis.com/<workspace_name>/<api_name> |
http_method | string | The request method that specifies the type of action that is to be performed. Make sure to specify the same method that was chosen while creating the custom API. Possible values: GET, POST, PUT, DELETE |
content_type (Optional) | string | Format and structure of data being sent in a request while the custom API is performed. This parameter is applicable only for POST and PUT request methods. Note:
|
payload (Optional) | object | Form data is supplied in JSON format to include and update records in the form. This parameter is applicable only for POST and PUT request methods. The keys in the key-value pairs will be the arguments specified while you create the function based on which the custom API works. Retrieve the arguments from the Summary section when the required custom API is accessed from the Microservices module in your Creator application. |
query_params (Optional) | - | Data can be sent as query parameters appended to the end of the URL. This parameter is applicable only for GET and DELETE request methods. |
public_key (Optional (Mandatory if custom API is configured with Public Key authentication) | string | The public key value received after configuring the custom API with a Public Key authentication. Choosing this authentication allows all users of the organization to invoke the custom API. Retrieve the public key from the Summary section when the required custom API is accessed from the Microservices module in your Creator application. |
Possible Errors
Refer to this page for the complete list of error codes and messages.