Copy Workspace
The Copy Workspace API is used to copy the workspace from one Zoho Analytics Account to another Zoho Analytics Account.
REQUEST URI
https://<ZohoAnalytics_Server_URI>/api/<SourceEmail>/<SourceWorkspaceName>
Post
oauthscope: ZohoAnalytics.modeling.create
COMMON PARAMETERS
Parameter | Possible Values | Description |
---|---|---|
ZOHO_ACTION | COPYDATABASE | This parameter specifies the action to be performed by the API request. |
ZOHO_OUTPUT_FORMAT | XML/JSON | This parameter specifies the output format for the response. |
ZOHO_ERROR_FORMAT | XML/JSON | Specifies the output format for the response in case an error occurs when trying to process the request. |
ZOHO_API_VERSION | 1.0 | The API version of Zoho Analytics based on which the application(/service) has been written. This parameter allows the Zoho Analytics to handle applications based on the older versions.The current API version is 1.0. |
AUTHORIZATION
To make authenticated API request, append the access token in Authorization request header.
Header Name | Value | Description |
---|---|---|
Authorization | Zoho-oauthtoken<space><destination_account_access_token> | The Access token provides a secure and temporary access to Zoho Analytics API's. Each access token will be valid only for an hour, and can be used only for the set of operations that is described in the scope. |
ACTION SPECIFIC PARAMETERS
Parameter Name | Possible Values | Description |
---|---|---|
ZOHO_DATABASE_NAME (mandatory) | <Workspace_name> | This parameter holds the name of the destination workspace |
ZOHO_DATABASE_DESC (optional) | <Workspace_description> | This parameter holds the description of the destination workspace |
ZOHO_COPY_WITHDATA (optional) | true/false |
|
COPY_WITH_IMPORT_SOURCE (optional) | true/false | By default it will be false.
|
ZOHO_COPY_DB_KEY (mandatory) | <Workspace_key> | The secret key used for allowing the user to copy the Workspace / Reports.
|
POSSIBLE ERROR CODES
7101 , 7103 , 7138 , 8024 , 8504 , 8506 , 8516 , 8533 , 15007
Sample Request:
Copiedcurl -d "ZOHO_ACTION=COPYDATABASE&ZOHO_OUTPUT_FORMAT=XML&ZOHO_ERROR_FORMAT=XML
&ZOHO_API_VERSION=1.0
&ZOHO_DATABASE_NAME=New Workspace Name&ZOHO_COPY_DB_KEY=
************"
-H "Authorization:Zoho-oauthtoken <access_token>"
https://analyticsapi.zoho.com/api/EmailAddress/WorkspaceName
Copiedusing ZReports;
namespace Test
{
class Program
{
public IReportClient GetClient()
{
IReportClient RepClient = new ReportClient(CLIENT_ID, CLIENT_SECRET, REFRESH_TOKEN);
return RepClient;
}
public void CopyDatabase(IReportClient RepClient)
{
string dbURI = RepClient.GetURI(EMAIL, DBNAME);
string newDBName = "newdbname";
string newDBDesc = "dbdesc";
bool withData = true;
string copyDBKey = "************";
long dbid = RepClient.CopyDatabase(dbURI, newDBName, newDBDesc, withData, copyDBKey, null);
}
static void Main(string[] args)
{
Program obj = new Program();
IReportClient rc = obj.GetClient();
obj.CopyDatabase(rc);
}
}
}
Copiedpackage main
import (
"fmt"
"zoho/pkg/reportclient"
)
var (
email = "Email Address"
dbname = "Workspace Name"
clientid = "************"
clientsecret = "************"
refreshtoken = "************"
dbkey = "************"
)
func copydatabase() {
url := reportclient.GetDbUri(email, dbname)
newdbname := "Sample"
params := map[string]string{}
newid, err := reportclient.CopyDatabase(url, newdbname, dbkey, params)
if err != nil {
fmt.Println(err.ErrorMessage)
fmt.Println(err.ErrorCode)
fmt.Println(err.Action)
fmt.Println(err.HttpStatusCode)
} else {
fmt.Println(newid)
}
}
func main() {
reportclient.SetOAuthToken(clientid, clientsecret, refreshtoken)
copydatabase()
}
Copiedimport com.adventnet.zoho.client.report.*;
public class Sample {
String email = "Email Address";
String dbname = "Workspace Name";
String clientId = "************";
String clientSecret = "************";
String refreshToken = "************";
Map config = new HashMap();
private ReportClient rc = new ReportClient(clientId, clientSecret, refreshToken);
public void copydatabase() throws Exception {
String uri = rc.getURI(email, dbname);
config.put("ZOHO_DATABASE_NAME", "database");
config.put("ZOHO_COPY_DB_KEY", "************");
long result = rc.copyDatabase(uri, config);
System.out.println(result);
}
public static void main(String[] args) throws Exception {
Sample obj = new Sample();
obj.copydatabase();
}
}
Copied<?php
require 'ReportClient.php';
$EMAIL_ID = "Email Address";
$DB_NAME = "Workspace Name";
$CLIENT_ID = "************";
$CLIENT_SECRET = "************";
$REFRESH_TOKEN = "************";
$report_client_request = new ReportClient($CLIENT_ID, $CLIENT_SECRET, $REFRESH_TOKEN);
$uri = $report_client_request->getDbURI($EMAIL_ID, $DB_NAME);
$db_key = "************ ";
$db_name = "Workspace Name";
$new_database_id = $report_client_request->copyDatabase($uri, $db_key, $db_name);
?>
Copiedfrom __future__ import with_statement
from ReportClient import ReportClient
import sys
class Sample:
LOGINEMAILID = "Email Address"
CLIENTID = "************"
CLIENTSECRET = "************"
REFRESHTOKEN = "************"
DATABASENAME = "Workspace Name"
rc = None
rc = ReportClient(REFRESHTOKEN, CLIENTID, CLIENTSECRET)
def CopyDatabase(self, rc):
uri = rc.getDBURI(self.LOGINEMAILID, self.DATABASENAME)
config = {"ZOHO_DATABASE_NAME": "new sales", "ZOHO_COPY_DB_KEY": "************"}
result = rc.copyDatabase(uri, config)
obj = Sample()
obj.CopyDatabase(obj.rc)
Copiedvar nodelib = require('./ZAnalyticsClient');
var clientId = '************';
var clientSecret = '************';
var refreshtoken = '************';
var emailId = 'EmailAddress';
var workspaceName = 'WorkspaceName';
var copydbkey = '************';
var newWorkspaceName = '';
nodelib.initialize(clientId, clientSecret, refreshtoken).then(() => {
var uripath = nodelib.getUri(emailId, workspaceName);
var params = {};
nodelib.copyWorkspace(newWorkspaceName, copydbkey, uripath, params).then((response) => {
console.log('Created Workspace ID : ' + response);
}).catch((error) => {
console.log('Error : ' + error.message);
});
}).catch((error) => {
console.log('Authentication Error : ' + error);
});
Copiedemail = zoho.encryption.urlEncode("");
workspaceName = zoho.encryption.urlEncode("");
paramsMap = Map();
oauthParams = Map();
headers = Map();
// AUTHENTICATION PARAMS
oauthParams.put("client_id", "********");
oauthParams.put("client_secret", "********");
oauthParams.put("refresh_token", "********");
oauthParams.put("grant_type", "refresh_token");
tokenInfo = invokeurl[url: "https://accounts.zoho.com/oauth/v2/token" type: POST parameters: oauthParams];
if (tokenInfo.containKey("access_token")) {
accessToken = tokenInfo.get("access_token");
headers.put("Authorization", "Zoho-oauthtoken ".concat(accessToken));
} else {
info tokenInfo;
return;
}
// COMMON PARAMS
paramsMap.put("ZOHO_ACTION", "COPYDATABASE");
paramsMap.put("ZOHO_OUTPUT_FORMAT", "JSON");
paramsMap.put("ZOHO_ERROR_FORMAT", "JSON");
paramsMap.put("ZOHO_API_VERSION", "1.0");
// ACTION SPECIFIC PARAMS
paramsMap.put("ZOHO_DATABASE_NAME", "");
paramsMap.put("ZOHO_COPY_DB_KEY", "");
response = invokeurl[url: "https://analyticsapi.zoho.com/api/" + email type: POST parameters: paramsMap headers: headers];
info response;
Sample Response:
Copied<responseuri="/api/EmailAddress/WorkspaceName"action="COPYDATABASE">
<result>
<message>
Successfully Workspace Copied
</message>
<dbid>
99999999999999
</dbid>
</result>
</response>
Copied{"response":
{"uri": "\/api\/email/WorkspaceName",
"action": "COPYDATABASE",
"result":
{"message": "Successfully Workspace Copied",
"dbid": "99999999999999"}}}