Create Table
The Create table API is used to Create a table in the specified workspace.
REQUEST URI
https://<ZohoAnalytics_Server_URI>/api/<OwnerEmail>/<WorkspaceName>
Post
oauthscope: ZohoAnalytics.modeling.create
TABLE DESIGN
{ "TABLENAME": "Table Name", "TABLEDESCRIPTION":"Table Description", "FOLDERNAME": "Target Folder", "COLUMNS": [ { "COLUMNNAME":"Column Name 1", "DATATYPE": "Column DataType", "DEFAULT":"Default Value", "MANDATORY" : "Yes/No", "DESCRIPTION" : "Column Description" }, { "COLUMNNAME":"Column Name 2", "DATATYPE": "Column DataType", "DEFAULT":"null", "MANDATORY" : "Yes/No", "DESCRIPTION" : "Column Description" } ] }
COMMON PARAMETERS
Parameter | Possible Values | Description |
---|---|---|
ZOHO_ACTION | CREATETABLE | 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
Parameter | Possible Values | Description |
---|---|---|
ZOHO_TABLE_DESIGN (mandatory) | Design content in JSON format | Table structure in JSON format (includes table name, description, folder name, column and lookup details).ID_JSON (optional) |
Sample Request:
Copiedcurl -d "ZOHO_ACTION=CREATETABLE&ZOHO_OUTPUT_FORMAT=XML&ZOHO_ERROR_FORMAT=XML&
ZOHO_API_VERSION=1.0&
ZOHO_TABLE_DESIGN="Table Design in JSON""
-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 CreateTable(IReportClient rc)
{
string uri = rc.GetURI(EMAIL, DBNAME);
string tableDesign = "{\"TABLENAME\":\"SysteTable\",\"TABLEDESCRIPTION\":\"Testing Purpose\",\"FOLDERNAME\":\"NewFolder\",\"COLUMNS\":[{\"COLUMNNAME\":\"SrNo\",\"DATATYPE\":\"NUMBER\",\"DEFAULT\":\"null\",\"MANDATORY\":\"Yes\",\"DESCRIPTION\":\"Testing\"}]}";
rc.CreateTable(uri, tableDesign, null);
}
static void Main(string[] args)
{
Program obj = new Program();
IReportClient rc = obj.GetClient();
obj.CreateTable(rc);
}
}
}
Copiedpackage main
import (
"fmt"
"zoho/pkg/reportclient"
)
var (
email = "Email Address"
dbname = "Workspace Name"
clientid = "************"
clientsecret = "************"
refreshtoken = "************"
)
func CreateTable() {
url := reportclient.GetDbUri(email, dbname)
tableConfig := "{\"TABLENAME\":\"SystemTable\",\"TABLEDESCRIPTION\":\"Testing Purpose\",\"FOLDERNAME\":\"NewFolder\",\"COLUMNS\":[{\"COLUMNNAME\":\"Product Category\",\"DATATYPE\":\"PLAIN\",\"DEFAULT\":\"Test\",\"MANDATORY\":\"Yes\",\"DESCRIPTION\":\"Testing2\"}]}"
err := reportclient.CreateTable(url, tableConfig)
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)
CreateTable()
}
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 CreateTable() throws Exception {
String uri = rc.getURI(email, dbname);
String tableDesign = "{\"TABLENAME\":\"SysteTable\",\"TABLEDESCRIPTION\":\"Testing Purpose\",\"FOLDERNAME\":\"NewFolder\",\"COLUMNS\":[{\"COLUMNNAME\":\"SrNo\",\"DATATYPE\":\"NUMBER\",\"DEFAULT\":\"null\",\"MANDATORY\":\"Yes\",\"DESCRIPTION\":\"Testing\"}]}";
rc.createTable(uri, tableDesign, config);
}
public static void main(String[] args) throws Exception {
Sample obj = new Sample();
obj.CreateTable();
}
}
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);
$table_design = '{
"TABLENAME": "SystemTable",
"TABLEDESCRIPTION": "Testing Purpose",
"FOLDERNAME": "NewFolder",
"COLUMNS": [
{
"COLUMNNAME": "SrNo",
"DATATYPE": "NUMBER",
"DEFAULT": "null",
"MANDATORY": "Yes",
"DESCRIPTION": "Testing"
},
{
"COLUMNNAME": "Product",
"DATATYPE": "null",
"DEFAULT": "null",
"MANDATORY": "Yes",
"DESCRIPTION": "Testing2"
},
{
"COLUMNNAME": "Product Category",
"DATATYPE": "PLAIN",
"DEFAULT": "Test",
"MANDATORY": "Yes",
"DESCRIPTION": "Testing2"
}
]
}';
$report_client_request->createTable($uri, $table_design);
?>
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 CreateTable(self, rc):
uri = rc.getDBURI(self.LOGINEMAILID, self.DATABASENAME)
tableDesign = '{"TABLENAME":"SysteTable","TABLEDESCRIPTION":"Testing Purpose","FOLDERNAME":"NewFolder","COLUMNS":[{"COLUMNNAME":"SrNo","DATATYPE":"NUMBER","DEFAULT":"null","MANDATORY":"Yes","DESCRIPTION":"Testing"}]}'
rc.createTable(uri, tableDesign)
obj = Sample()
obj.CreateTable(obj.rc)
Copiedvar nodelib = require('./ZAnalyticsClient');
var clientId = '************';
var clientSecret = '************';
var refreshtoken = '************';
var emailId = 'EmailAddress';
var workspaceName = 'WorkspaceName';
nodelib.initialize(clientId, clientSecret, refreshtoken).then(() => {
var params = {};
var uripath = nodelib.getUri(emailId, workspaceName);
var tableConfig = '{"TABLENAME":"Testing Table","TABLEDESCRIPTION":"Testing Purpose","FOLDERNAME":"NewFolder","COLUMNS":[{"COLUMNNAME":"Product Category","DATATYPE":"PLAIN","DEFAULT":"Test","MANDATORY":"Yes","DESCRIPTION":"Testing2"}]}';
nodelib.createTable(tableConfig, 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: 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", "CREATETABLE");
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_TABLE_DESIGN", "");
response = invokeurl[url: "https://analyticsapi.zoho.com/api/" + email + "/" + workspaceName type: POST parameters: paramsMap headers: headers];
info response;
Sample Response:
Copied<?xml version="1.0"encoding="UTF-8" ?>
<responseuri="/api/EmailAddress/WorkspaceName"action="CREATETABLE">
<result>
<message>Table created successfully!</message>
</result>
</response>
Copied{"response":
{"uri":"\/api\/email\/WorkspaceName",
"action":"CREATETABLE",
"result":
{"message":"Table created successfully!"}}}