Add Row
This API allows you to add a single row into a specified table.
REQUEST URI
https://<ZohoAnalytics_Server_URI>/api/<OwnerEmail>/<WorkspaceName>/<TableName>
Post
oauthscope: ZohoAnalytics.data.create
COMMON PARAMETERS
Parameter | Possible Values | Description |
---|---|---|
ZOHO_ACTION | ADDROW | This parameter specifies the action to be performed by the API request.Note: Value of ZOHO_ACTION parameter should be in the same case(UPPER CASE) as given in this document. |
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_DATE_FORMAT (optional) | Format of the date. E.g. dd-MMM-YYYY | 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. |
The column values for the row should be passed as POST parameters in <columnname>
=<value>
format. (The parameters should be in application/x-www-form-urlencoded format).
<columnname>
- Refers to the name of the column in the table to which the value is added.
<value>
- Refers to the corresponding value to be added for this column.
POSSIBLE ERROR CODES
7103 , 7138 , 7507 , 7511 , 8016 , 8504 , 8506 , 8516 , 8533
Sample Request:
Copiedcurl -d "ZOHO_ACTION=ADDROW&ZOHO_OUTPUT_FORMAT=XML&ZOHO_ERROR_FORMAT=XML
&ZOHO_API_VERSION=1.0&Id=999
&Name=Gary&Date Of Birth=12-Jun-1980&Salary=10000&Country=USA"
-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";
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 addRow(IReportClient RepClient)
{
string tableURI = RepClient.GetURI(EMAIL, DBNAME, TBNAME);
Dictionary<string, string> ColumnValues = new Dictionary
<string, string>();
Dictionary<string, string> Config = new Dictionary
<string, string>();
ColumnValues.Add("Region", "South");
Dictionary<string, string> addRowRes = RepClient.AddRow(tableURI,
ColumnValues, Config);
}
static void Main(string[] args)
{
Program obj = new Program();
IReportClient rc = obj.getClient();
obj.addRow(rc);
}
}
}
Copiedpackage main
import (
"fmt"
"zoho/pkg/reportclient"
)
var(
email = "Email Address"
dbname = "Workspace Name"
tbname = "Table Name"
clientid = "************"
clientsecret = "************"
refreshtoken = "************"
)
func addrow() {
url := reportclient.GetUri(email, dbname, tbname)
columnvalues := map[string]string{}
columnvalues["Id"] = "999"
columnvalues["Name"] = "zzz"
resultmap , err := reportclient.AddRow(url, columnvalues)
if(err != nil){
fmt.Println(err.ErrorMessage)
fmt.Println(err.ErrorCode)
fmt.Println(err.Action)
fmt.Println(err.HttpStatusCode)
}else{
fmt.Println(resultmap)
}
}
func main() {
reportclient.SetOAuthToken(clientid, clientsecret, refreshtoken)
addrow()
}
Copiedimport com.adventnet.zoho.client.report.*;
public class Sample
{
String email = "Email Address";
String dbname = "Workspace Name";
String tbname = "Table Name";
String clientId = "************";
String clientSecret = "************";
String refreshToken = "************";
Map config = new HashMap();
Map colval = new HashMap();
private ReportClient rc = new ReportClient(clientId, clientSecret, refreshToken);
public void addrow() throws Exception
{
String uri = rc.getURI(email,dbname,tbname);
colval.put("Id", 101);
colval.put("Name", "sam");
Map result = rc.addRow(uri,colval,config);
System.out.println(result);
}
public static void main(String[] args) throws Exception
{
Sample obj = new Sample();
obj.addrow();
}
}
Copied<?php
require 'ReportClient.php';
$EMAIL_ID = "Email Address";
$DB_NAME = "Workspace Name";
$TABLE_NAME = "Table Name";
$CLIENT_ID = "************";
$CLIENT_SECRET = "************";
$REFRESH_TOKEN = "************";
$report_client_request = new ReportClient($CLIENT_ID, $CLIENT_SECRET, $REFRESH_TOKEN);
$uri = $report_client_request->getURI($EMAIL_ID, $DB_NAME, $TABLE_NAME);
$column_values = array("Employee Name" => "Shankar", "Employee ID" =>
"2015", "Experience" => "5");
$response_array = $report_client_request->addRow($uri, $column_values);
?>
Copiedfrom __future__ import with_statement
from ReportClient import ReportClient
import sys
class Sample:
LOGINEMAILID="Email Address"
CLIENTID="************"
CLIENTSECRET="************"
REFRESHTOKEN="************"
DATABASENAME="Workspace Name"
TABLENAME="Table Name"
rc = None
rc = ReportClient(REFRESHTOKEN, CLIENTID, CLIENTSECRET)
def AddRow(self,rc):
uri = rc.getURI(self.LOGINEMAILID,self.DATABASENAME,self.TABLENAME)
rowData = {"Date":"01 Jan, 2009 00:00:00","Region":"East","Product
Category": "Samples","Product":"SampleProduct","Customer Name":
"Sample", "Sales":2000,"Cost":2000}
result = rc.addRow(uri,rowData,None)
print result
obj = Sample()
obj.AddRow(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 = {};
params['Rank'] = 1;
params['Country'] = 'France';
params['Gold'] = 7;
var uripath = nodelib.getUri(emailId, workspaceName, viewName);
nodelib.addRow(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("");
viewName = 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","ADDROW");
paramsMap.put("ZOHO_OUTPUT_FORMAT","JSON");
paramsMap.put("ZOHO_ERROR_FORMAT","JSON");
paramsMap.put("ZOHO_API_VERSION","1.0");
//VALUES TO BE ADDED
paramsMap.put("<column_name_1>","<value>");
paramsMap.put("<column_name_2>","<value>");
response = invokeurl
[
url :"https://analyticsapi.zoho.com/api/" + email + "/" + workspaceName + "/" + viewName
type :POST
parameters:paramsMap
headers:headers
];
info response;
Show full
Show less
Sample Response:
Copied{
"response":
{
"url": "/api/EmailAddress/WorkspaceName/TableName",
"action": "ADDROW",
"result":
{
"column_order":["Name","Date Of Birth","Salary","Country"],
"rows":["Gary","12-Jun-1980",10000,"USA"]
}
}
}
Copied<?xml version="1.0" encoding="UTF-8" ?>
<response url ="/api/EmailAddress/WorkspaceName/TableName"action="ADDROW">
<result>
<!-- All the columns in the row , including formula columns -->
<row>
<column name="Name">Gary</column>
<column name="Date Of Birth">12-Jun-1980</column>
<column name="Basic">10000</column>
<column name="Country">USA</column>
</row>
</result>
</response>
Show full
Show less