Create Similar Views
The create similar views API is used to generate the reports from your Zoho Analytics table.The views are created based on the reference table views.
REQUEST URI
https://<ZohoAnalytics_Server_URI>/api/<OwnerEmail>/<WorkspaceName>/<TableName>
Post
oauthscope: ZohoAnalytics.modeling.create
COMMON PARAMETERS
Parameter | Possible Values | Description |
---|---|---|
ZOHO_ACTION | CREATESIMILARVIEWS | 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><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)
Parameter | Possible Values | Description |
---|---|---|
ZOHO_REFVIEW (mandatory) | Reference view name | This parameter holds the name of the reference view name. |
ZOHO_FOLDERNAME (mandatory) | Destination folder name | This parameter holds the folder name where the views to be saved. |
ISCOPYCUSTOMFORMULA (mandatory) | True / False | True - Custom formulas are copied in the new views also. False - Custom formulas are not handled in new views. |
ISCOPYAGGFORMULA (mandatory) | True / False | True - Aggregate formulas are copied in the new views also. False - Aggregate formulas are not handled in new views. |
POSSIBLE ERROR CODES
Sample Request:
Copiedcurl
-d "ZOHO_ACTION=CREATESIMILARVIEWS&ZOHO_OUTPUT_FORMAT=XML&ZOHO_ERROR_FORMAT=XML&ZOHO_API_VERSION=1.0&ZOHO_REFVIEW=Reference Table Name&ZOHO_FOLDERNAME=Folder Name&ISCOPYCUSTOMFORMULA=false&ISCOPYAGGFORMULA=false"
-H "Authorization:Zoho-oauthtoken <access_token>"
https://analyticsapi.zoho.com/api/EmailAddress/WorkspaceName/TableName
Copiedusing ZReports;
namespace Test
{
CLIENT_ID = "************";
CLIENT_SECRET = "************";
REFRESH_TOKEN = "************";
EMAIL = "Email Address";
class Program
{
public IReportClient getClient()
{
IReportClient RepClient = new ReportClient(CLIENT_ID, CLIENT_SECRET, REFRESH_TOKEN);
return RepClient;
}
public void createsimilarviews(IReportClient rc)
{
try
{
string uri = rc.GetURI(EMAIL, "Workspace name", "Table Name");
string refview = "Reference Table Name";
string foldername = "Folder Name";
bool copycusformula = false;
bool copyaggformula = false;
rc.CreateSimilarViews(uri, refview, foldername, copycusformula, copyaggformula, null);
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
static void Main(string[] args)
{
Program obj = new Program();
IReportClient rc = obj.getClient();
obj.createsimilarviews(rc);
}
}
}
Copiedpackage main
import (
"fmt"
"zoho/pkg/reportclient"
)
var (
email = "User Email"
clientid = "************"
clientsecret = "************"
refreshtoken = "************"
)
func CreateSimilarViews() {
url := reportclient.GetUri(email, "Workspace Name", "Table Name")
refview := "Reference Table Name"
foldername := "Folder Name"
customformula := false
aggformula := false
params := map[string]string{}
result, err := reportclient.CreateSimilarViews(url, refview, foldername, customformula, aggformula, params)
if err != nil {
fmt.Println(err.ErrorMessage)
fmt.Println(err.ErrorCode)
fmt.Println(err.Action)
fmt.Println(err.HttpStatusCode)
} else {
fmt.Println(result)
}
}
func main() {
reportclient.SetOAuthToken(clientid, clientsecret, refreshtoken)
CreateSimilarViews()
}
Copiedimport com.adventnet.zoho.client.report.*;
public class Sample {
String email = "Email Address";
String databaseName = "Workspace Name";
String tableName = "Table Name";
String clientId = "************";
String clientSecret = "************";
String refreshToken = "************";
Map config = new HashMap();
private ReportClient rc = new ReportClient(clientId, clientSecret, refreshToken);
public void createSimilarViews() throws Exception {
String uri = rc.getURI(email, databaseName, tableName);
String refView = "Reference Table Name";
String folderName = "Folder Name";
boolean customFormula = false;
boolean aggFormula = false;
Map result = rc.createSimilarViews(uri, refView, folderName, customFormula, aggFormula, null);
}
public static void main(String[] args) throws Exception {
Sample obj = new Sample();
obj.createSimilarViews();
}
}
Copied<?php
require 'ReportClient.php';
$EMAIL_ID = "Email Address";
$CLIENT_ID = "************";
$CLIENT_SECRET = "************";
$REFRESH_TOKEN = "************";
$DB_NAME = "Workspace Name";
$TABLE_NAME = "Table Name";
$request = new ReportClient($CLIENT_ID, $CLIENT_SECRET, $REFRESH_TOKEN);
$uri = $request->getURI($EMAIL_ID, $DB_NAME, $TABLE_NAME);
$ref_view = "Reference Table Name";
$folder_name = "Folder Name";
$copy_customformula = false;
$copy_aggformula = false;
$response = $request->createSimilarViews($uri, $ref_view, $folder_name, $copy_customformula, $copy_aggformula);
?>
Copiedfrom __future__ import with_statement
from ReportClient import ReportClient
import sys
class Sample:
LOGIN_EMAIL_ID = "Email Address"
DATABASE_NAME = "Workspace Name"
TABLE_NAME = "Table Name"
CLIENT_ID = "************"
CLIENT_SECRET = "************"
REFRESH_TOKEN = "************"
rc = None
rc = ReportClient(REFRESH_TOKEN, CLIENT_ID, CLIENT_SECRET)
def createSimilarViews(self, rc):
uri = rc.getURI(self.LOGIN_EMAIL_ID, self.DATABASE_NAME, self.TABLE_NAME)
refView = "Reference Table Name"
folderName = "Folder Name"
customFormula = False
aggFormula = False
result = rc.createSimilarViews(uri, refView, folderName, customFormula, aggFormula, None)
print(result)
obj = Sample()
obj.createSimilarViews(obj.rc)
Copiedvar nodelib = require('./ZAnalyticsClient');
var clientId = '************';
var clientSecret = '************';
var refreshtoken = '************';
var emailId = 'EmailAddress';
var workspaceName = 'WorkspaceName';
var viewName = 'ViewName';
nodelib.initialize(clientId, clientSecret, refreshtoken).then(() => {
var params = {};
var uripath = nodelib.getUri(emailId, workspaceName, viewName);
var referenceView = '';
var folderName = '';
var copyCustomFormula = '';
var copyAggregateFormula = '';
nodelib.createSimilarViews(referenceView, folderName, copyCustomFormula, copyAggregateFormula, 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", "CREATESIMILARVIEWS");
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_REFVIEW", "");
paramsMap.put("ZOHO_FOLDERNAME", "");
paramsMap.put("ISCOPYCUSTOMFORMULA", "");
paramsMap.put("ISCOPYAGGFORMULA", "");
response = invokeurl[url: "https://analyticsapi.zoho.com/api/" + email + "/" + workspaceName
type: POST parameters: paramsMap headers: headers];
info response;
Sample Response:
Copied<responseuri="/api/EmailAddress/WorkspaceName/TableName"action="CREATESIMILARVIEWS">
<result>
<status>success</status>
<message>Reports created successfully</message>
</result>
</response>
Copied{"response":
{"uri": "\/api\/email\/WorkspaceName\/TableName",
"action": "CREATESIMILARVIEWS",
"result":
{"status":"Success",
"message":"Reports created successfully"}}}