Copy Reports

The source workspace administrator should generate and provide the Copy Workspace Key, the secret key used to authorize the destination workspace administrator. Copying the reports using this API will copy the report along with the relationships involved and the formula columns associated with the source report. It is necessary that the parent tables of the view in the source workspace should exists with the same name in the destination workspace.

REQUEST URI

https://<ZohoAnalytics_Server_URI>/api/<SourceEmail>/<SourceWorkspaceName>

Post

oauthscope: ZohoAnalytics.modeling.create

COMMON PARAMETERS

ParameterPossible ValuesDescription
ZOHO_ACTIONCOPYREPORTS This parameter specifies the action to be performed by the API request.
ZOHO_OUTPUT_FORMATXML/JSONThis parameter specifies the output format for the response.
ZOHO_ERROR_FORMATXML/JSONSpecifies the output format for the response in case an error occurs when trying to process the request.
ZOHO_API_VERSION1.0The 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 NameValueDescription
AuthorizationZoho-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 (DATA FOR THE ROW)

ParameterPossible ValuesDescription
ZOHO_VIEWTOCOPY
(mandatory) 
view names

This parameter holds the list of view names. In case of more than one views, the view names should be separated by comma ( , ). 

Example:ZOHO_VIEWTOCOPY=View1,View2,View3,…

ZOHO_DATABASE_NAME
(mandatory)
Workspace nameThis parameter holds the name of the workspace (destination workspace) where the reports (specified in ZOHO_VIEWSTOCOPY parameter) has to be copied.
ZOHO_COPY_DB_KEY
(mandatory)        
Workspace key

The secret key used for allowing the user to copy the Workspace / Reports.

The source Workspace Admin has to create the Copy Workspace Secret Key. For more about workspace key.

Note: You need to provide the appropriate values in the above URL to generate the corresponding Copy Workspace Key for your setup.

ZOHO_COPY_WITHDATA
(optional)
true/false

Default value is false.

true - The data present in source view will be copied to the created view.

false - The data present in source table will not be copied to the created view.

POSSIBLE ERROR CODES

7103 , 7138 , 8504 , 8506 , 8516 , 8533 , 15000 , 15001 , 15002 , 15005 , 15007 , 15012

Sample Request:

Copiedcurl 
-d "ZOHO_ACTION=COPYREPORTS&ZOHO_OUTPUT_FORMAT=XML&ZOHO_ERROR_FORMAT=XML&ZOHO_API_VERSION=1.0&ZOHO_VIEWTOCOPY=View1,View2&ZOHO_DATABASE_NAME=Destination Workspace name&ZOHO_COPY_DB_KEY=************" 
-H "Authorization:Zoho-oauthtoken <access_token>" 
https://analyticsapi.zoho.com/api/<SourceEmail>/<SourceWorkspaceName>
Copiedusing ZReports;

namespace Test
{
    CLIENT_ID = "************";
    CLIENT_SECRET = "************";
    REFRESH_TOKEN = "************";
    EMAIL = "Email Address";
    DBNAME = "Workspace Name";
    TBNAME = "Table Name";

    class Program
    {
        public IReportClient getClient()
        {
            IReportClient RepClient = new ReportClient(CLIENT_ID, CLIENT_SECRET, REFRESH_TOKEN);
            return RepClient;
        }

        public void copyreports(IReportClient rc)
        {
            string uri = rc.GetURI(EMAIL, DBNAME);
            string views = "View1,View2";
            string dbname = "Destination Workspace Name";
            string dbkey = "************";
            rc.CopyReports(uri, views, dbname, dbkey, null);
        }

        static void Main(string[] args)
        {
            Program obj = new Program();
            IReportClient rc = obj.getClient();
            obj.copyreports(rc);
        }
    }
}
Copiedpackage main

import (
	"fmt"
	"zoho/pkg/reportclient"
)

var (
	email        = "Email Address"
	dbname       = "Workspace Name"
	clientid     = "************"
	clientsecret = "************"
	refreshtoken = "************"
	dbkey        = "*************"
)

func copyreports() {
	url := reportclient.GetDbUri(email, dbname)
	viewnames := "View1,View2"
	destdbname := "Destination Workspace Name"
	err := reportclient.CopyReports(url, viewnames, destdbname, dbkey)
	if err != nil {
		fmt.Println(err.ErrorMessage)
		fmt.Println(err.ErrorCode)
		fmt.Println(err.Action)
		fmt.Println(err.HttpStatusCode)
	} else {
		fmt.Println("Success")
	}
}

func main() {
	reportclient.SetOAuthToken(clientid, clientsecret, refreshtoken)
	copyreports()
}
Copiedimport com.adventnet.zoho.client.report.*;

public class Sample {
    String email = "Email Address";
    String dbname = "Workspace Name";
    String clientId = "************";
    String clientSecret = "************";
    String refreshToken = "************";
    String dbkey = "************";
    String destdb = "Destination Workspace Name";
    String views = "View1,View2";
    Map config = new HashMap();
    private ReportClient rc = new ReportClient(clientId, clientSecret, refreshToken);

    public void copyreports() throws Exception {
        String uri = rc.getURI(email, dbname);
        rc.copyReport(uri, views, destdb, dbkey, config);
    }

    public static void main(String[] args) throws Exception {
        Sample obj = new Sample();
        obj.copyreports();
    }
}
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);
$views = "View1,View2";
$dbname = "Destination Workspace Name";
$dbkey = "************";
$report_client_request->copyReports($uri, $views, $dbname, $dbkey);
?>
Copiedfrom __future__ import with_statement
from ReportClient import ReportClient
import sys

class Sample:
    LOGIN_EMAIL_ID = "Email Address"
    DATABASE_NAME = "Workspace Name"
    rc = None
    rc = ReportClient(REFRESH_TOKEN, CLIENT_ID, CLIENT_SECRET)

    def copyreports(self, rc):
        uri = rc.getDBURI(self.LOGIN_EMAIL_ID, self.DATABASE_NAME)
        rc.copyReports(uri, "View1,View2", "Destination Workspace Name", "***********")

    obj = Sample()
    obj.copyreports(obj.rc)
Copiedvar nodelib = require('./ZAnalyticsClient');
var clientId = '************';
var clientSecret = '************';
var refreshtoken = '************';
var emailId = 'EmailAddress';
var workspaceName = 'WorkspaceName';
var copydbkey = '';
nodelib.initialize(clientId, clientSecret, refreshtoken).then(() => {
    var params = {};
    var uripath = nodelib.getUri(emailId, workspaceName);
    var viewNames = '';
    var destWorkspaceName = '';
    nodelib.copyReports(viewNames, destWorkspaceName, copydbkey, uripath, params).then((response) => {
        console.log(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:POSTparameters: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", "COPYREPORTS");
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_VIEWTOCOPY", "");
paramsMap.put("ZOHO_DATABASE_NAME", "");
paramsMap.put("ZOHO_COPY_DB_KEY", "");
response = invokeurl[url: "https://analyticsapi.zoho.com/api/" + email + "/" + workspaceName
    type: POST parameters: paramsMap headers: headers];
info response;

Download SDK : C# | GO | JAVA | PHP | PYTHON | NodeJS

Sample Response:

Copied<responseuri="/api/EmailAddress/WorkspaceName"
action="COPYREPORTS">
    <result>
        <message>
        Successfully View(s) Copied
        </message>
    </result>
</response>
Copied{"response":
    {"uri":"\/api\/email\/WorkspaceName",
        "action":"COPYREPORTS",
        "result":
        {"message": "Successfully View(s) Copied"}}}