Use Connections

Summary

This guide explains how to utilize connections within your Zoho Writer extension code. It covers integrating connection JSON into your plugin-manifest file and using the Request Method to securely make authenticated API requests.

Purpose

  • Copy connection JSON from Sigma and add to plugin-manifest.json
  • Use the Request Method with connectionLinkName in your extension code
  • Let Zoho handle authorization, token management, and proxying
  • Make secure authenticated API calls without exposing credentials

Step 1: Get Connection JSON

  1. Navigate to your created connection in Sigma
  2. Click Connection Details
  3. Select the JSON tab under "Sample Code"
  4. Click Copy to copy the connection JSON

Step 2: Add to Plugin-Manifest

{
  "service": "WRITER",
  "modules": {
    "widgets": [ ... ]
  },
  "connectors": [
    {
      "name": "my_connection",
      "type": "OAuth",
      "authorizationUrl": "https://...",
      "scopes": ["api", "refresh_token"]
    }
  ]
}

Step 3: Use Request Method in Widget HTML

Request Method Parameters

ParameterTypeRequiredDescription
connectionLinkNameStringYesName of connection from plugin-manifest
typeStringYesHTTP method (GET, POST, PUT, DELETE)
urlStringYesAPI endpoint URL
headersObjectNoOptional custom HTTP headers
postBodyObject/StringNoRequest body for POST/PUT

Related Pages

Sample Request

Copied<!DOCTYPE html>
<html>
<head>
    <title>API Integration Widget</title>
    <script src="https://static.zohocdn.com/sigma/client/sdk/v3/sigma-sdk.min.js"></script>
    <style>
        body { font-family: Arial, sans-serif; padding: 20px; }
        button { padding: 10px 20px; cursor: pointer; }
        #response { margin-top: 20px; padding: 10px; background: #f0f0f0; }
    </style>
</head>
<body>
    <h1>API Integration Widget</h1>
    <button onclick="fetchData()">Fetch Data</button>
    <div id="response"></div>

    <script>
        SigmaSDK.WRITER.init();

        function fetchData() {
            SigmaSDK.WRITER.request({
                connectionLinkName: "my_salesforce_connection",
                type: "GET",
                url: "https://api.example.com/v1/accounts"
            })
            .then(function(response) {
                document.getElementById("response").innerHTML =
                    "<p>Data: " + JSON.stringify(response) + "</p>";
            })
            .catch(function(error) {
                SigmaSDK.WRITER.showMessage({
                    type: "error",
                    message: "Request failed: " + error.message
                });
            });
        }
    </script>
</body>
</html>

Fetch Data Sample Request

Copied<!DOCTYPE html>
<html>
<head>
    <title>API Integration Widget</title>
    <script src="https://static.zohocdn.com/sigma/client/sdk/v3/sigma-sdk.min.js"></script>
    <style>
        body { font-family: Arial, sans-serif; padding: 20px; }
        button { padding: 10px 20px; cursor: pointer; }
        #response { margin-top: 20px; padding: 10px; background: #f0f0f0; }
    </style>
</head>
<body>
    <h1>API Integration Widget</h1>
    <button onclick="fetchData()">Fetch Data</button>
    <div id="response"></div>

    <script>
        SigmaSDK.WRITER.init();

        function fetchData() {
            SigmaSDK.WRITER.request({
                connectionLinkName: "my_salesforce_connection",
                type: "GET",
                url: "https://api.example.com/v1/accounts"
            })
            .then(function(response) {
                document.getElementById("response").innerHTML =
                    "<p>Data: " + JSON.stringify(response) + "</p>";
            })
            .catch(function(error) {
                SigmaSDK.WRITER.showMessage({
                    type: "error",
                    message: "Request failed: " + error.message
                });
            });
        }
    </script>
</body>
</html>

Create Data Sample Request

CopiedSigmaSDK.WRITER.request({
    connectionLinkName: "my_connection",
    type: "GET",
    url: "https://api.example.com/users"
}).then(response => console.log(response))
  .catch(error => console.error(error));

Update Data Sample Request

CopiedSigmaSDK.WRITER.request({
    connectionLinkName: "my_connection",
    type: "POST",
    url: "https://api.example.com/records",
    postBody: { name: "New Record", email: "user@example.com" }
}).then(response => console.log("Created:", response));

Error Handling Sample Request

CopiedSigmaSDK.WRITER.request({
    connectionLinkName: "my_connection",
    type: "PUT",
    url: "https://api.example.com/records/123",
    postBody: { name: "Updated Name", status: "Active" }
});