Link Workspaces

Link one or more client workspaces to the specified master workspace.

REQUEST URI

https://<ZohoAnalytics_Server_URI>/restapi/v2/workspaces/<workspace-id>/linkedworkspaces

Post

oauthscope: ZohoAnalytics.modeling.create

QUERY PARAMETERS

 

Parameter Name
Description
CONFIG*JSONObject
Config parameter specifications are available in the below section.

FIELDS FOR CONFIG JSON

 

Key
Description
clients*JSONArray
The client workspaces to link, grouped by the organization that owns them.
Supports 1 to 100 entries.
Maximum length - 500000 characters.
Check the table clients Fields for more details.

Sample: {"clients":[{"orgId":700000654321,"workspaceIds":["466206000000071000"]}]}

Note: Workspaces that are already linked to this master workspace are skipped. If no workspaces remain to be linked, the API returns a success response without linking anything.

 

Key
Description
orgId*Long
The ID of the organization that owns the listed workspaces.
Specify the value as a JSON number.
Maximum length - 20 characters.
You must be an Account Admin or Organization Admin of this organization.

Sample: {"orgId":700000654321}
workspaceIds*JSONArray of String
The IDs of the client workspaces to link.
Specify each workspace ID as a string.
Supports 1 to 100 entries.
Maximum length - 5000 characters.
Every workspace must belong to the organization specified in orgId.
Duplicate workspace IDs are removed before processing.

Sample: {"workspaceIds":["466206000000071000"]}

Note: Specify orgId as a number and each entry in workspaceIds as a string, as shown in the samples.

Sample Request:

Copiedcurl "https://analyticsapi.zoho.com/restapi/v2/workspaces/<workspace-id>/linkedworkspaces" \
  -X 'POST' \
  -H 'ZANALYTICS-ORGID: <org-id>' \
  -H 'Authorization: Zoho-oauthtoken <access_token>' \
  --data-urlencode 'CONFIG={"clients":[{"orgId":700000654321,"workspaceIds":["466206000000071000"]}]}'
Copiedusing System;
using System.Collections.Generic;
using System.Text.Json;
using ZohoAnalytics;

namespace ZohoAnalyticsTest
{
    class Program
    {
        long orgId = 55522777;
        long workspaceId = 35130000001055707;

        public void LinkWorkspaces(IAnalyticsClient ac)
        {
            List<Dictionary<string, object>> clients = JsonSerializer.Deserialize<List<Dictionary<string, object>>>("[{\"orgId\":700000654321,\"workspaceIds\":[\"466206000000071000\"]}]");
            IWorkspaceAPI workspace = ac.GetWorkspaceInstance(orgId, workspaceId);
            workspace.LinkWorkspaces(clients, null);
            Console.WriteLine("success");
        }

        static void Main(string[] args)
        {
            string clientId = "1000.xxxxxxx";
            string clientSecret = "xxxxxxx";
            string refreshToken = "1000.xxxxxxx.xxxxxxx";
            IAnalyticsClient ac = new AnalyticsClient(clientId, clientSecret, refreshToken);
            Program obj = new Program();
            obj.LinkWorkspaces(ac);
        }
    }
}
Copiedpackage main

import (
    "fmt"
    ZAnalytics "zoho/pkg/analyticsclient"
)

var (
    clientId = "1000.xxxxxxx"
    clientSecret = "xxxxxxx"
    refreshToken = "1000.xxxxxxx.xxxxxxx"
    orgId = "55522777"
    workspaceId = "35130000001055707"
)

func LinkWorkspaces(ac ZAnalytics.Client) {
    clients := []interface{}{
        map[string]interface{}{
            "orgId": 700000654321,
            "workspaceIds": []string{"466206000000071000"},
        },
    }
    workspace := ZAnalytics.GetWorkspaceInstance(&ac, orgId, workspaceId)
    exception := workspace.LinkWorkspaces(clients, nil)
    if exception != nil {
        fmt.Println(exception.ErrorMessage)
        return
    }
    fmt.Println("success")
}

func main() {
    ac := ZAnalytics.GetAnalyticsClient(clientId, clientSecret, refreshToken)
    LinkWorkspaces(ac)
}
Copiedimport com.zoho.analytics.client.*;
import org.json.*;

public class Test {
    private long orgId = 55522777l;
    private long workspaceId = 35130000001055707l;

    public static void main(String args[]) {
        String clientId = "1000.xxxxxxx";
        String clientSecret = "xxxxxxx";
        String refreshToken = "1000.xxxxxxx.xxxxxxx";
        Test tObj = new Test();
        AnalyticsClient ac = new AnalyticsClient(clientId, clientSecret, refreshToken);
        try {
            tObj.linkWorkspaces(ac);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    public void linkWorkspaces(AnalyticsClient ac) throws Exception {
        JSONArray clients = new JSONArray("[{\"orgId\":700000654321,\"workspaceIds\":[\"466206000000071000\"]}]");
        WorkspaceAPI workspace = ac.getWorkspaceInstance(orgId, workspaceId);
        workspace.linkWorkspaces(clients, null);
        System.out.println("success");
    }
}
Copied<?php
require 'AnalyticsClient.php';

class Test {
    public $ac;
    public $org_id = "55522777";
    public $workspace_id = "35130000001055707";

    function __construct() {
        $this->ac = new AnalyticsClient("1000.xxxxxxx", "xxxxxxx", "1000.xxxxxxx.xxxxxxx");
    }

    function linkWorkspaces() {
        $clients = array(
            array(
                "orgId" => 700000654321,
                "workspaceIds" => array("466206000000071000")
            )
        );
        $workspace = $this->ac->getWorkspaceInstance($this->org_id, $this->workspace_id);
        $workspace->linkWorkspaces($clients);
        echo "success";
    }
}

$obj = new Test();
$obj->linkWorkspaces();
?>
Copiedfrom AnalyticsClient import AnalyticsClient

class Config:
    CLIENTID = "1000.xxxxxxx"
    CLIENTSECRET = "xxxxxxx"
    REFRESHTOKEN = "1000.xxxxxxx.xxxxxxx"
    ORGID = "55522777"
    WORKSPACEID = "35130000001055707"

class Sample:
    ac = AnalyticsClient(Config.CLIENTID, Config.CLIENTSECRET, Config.REFRESHTOKEN)

    def link_workspaces(self, ac):
        clients = [
            {
                "orgId": 700000654321,
                "workspaceIds": ["466206000000071000"]
            }
        ]
        workspace = ac.get_workspace_instance(Config.ORGID, Config.WORKSPACEID)
        workspace.link_workspaces(clients)
        print("success")

obj = Sample()
obj.link_workspaces(obj.ac)
Copiedvar analyticsClient = require('./AnalyticsClient');
var ac = new analyticsClient('1000.xxxxxxx', 'xxxxxxx', '1000.xxxxxxx.xxxxxxx');
var orgId = '55522777';
var workspaceId = '35130000001055707';

var clients = [
    {
        "orgId": 700000654321,
        "workspaceIds": ["466206000000071000"]
    }
];
var workspace = ac.getWorkspaceInstance(orgId, workspaceId);
workspace.linkWorkspaces(clients).then(() => { console.log("success"); }).catch((error) => { console.log(error); });
CopiedorgId = "55522777";
workspaceId = "35130000001055707";
headersMap = Map();
headersMap.put("ZANALYTICS-ORGID", orgId);
config = {"clients": [{"orgId": 700000654321, "workspaceIds": ["466206000000071000"]}]};
response = invokeurl
parameters = "CONFIG=" + zoho.encryption.urlEncode(config.toString());
[
  url :"https://analyticsapi.zoho.com/restapi/v2/workspaces/" + workspaceId + "/linkedworkspaces"
  type :POST
  parameters:parameters
  headers:headersMap
  connection:"analytics_oauth_connection"
];
info response;
Copiedrequire 'zoho_analytics_client'

class Config
  ORGID = "55522777"
  WORKSPACEID = "35130000001055707"
end

class Sample
  def initialize
    @ac = AnalyticsClient.new.with_data_center("US").with_oauth({
      "clientId" => "1000.xxxxxxx",
      "clientSecret" => "xxxxxxx",
      "refreshToken" => "1000.xxxxxxx.xxxxxxx"
    }).build
  end

  def link_workspaces
    clients = [
      {
        "orgId" => 700000654321,
        "workspaceIds" => ["466206000000071000"]
      }
    ]
    workspace = @ac.get_workspace_instance(Config::ORGID, Config::WORKSPACEID)
    workspace.link_workspaces(clients)
    puts "success"
  end
end

obj = Sample.new
obj.link_workspaces

Download client libraries:  C# | GO | JAVA | PHP | PYTHON | NodeJS | Ruby

Sample value for CONFIG parameter:

Copied{
  "clients": [
    {
      "orgId": 700000654321,
      "workspaceIds": [
        "466206000000071000"
      ]
    }
  ]
}

Sample Response:

CopiedHTTP/1.1 204 No Content