Update Data

The data present in a table can be updated using this API.

REQUEST URI

https://<ZohoAnalytics_Server_URI>/api/<OwnerEmail>/<WorkspaceName>/<TableName>

Post

oauthscope: ZohoAnalytics.data.update

COMMON PARAMETERS

ParameterPossible ValuesDescription
ZOHO_ACTIONUPDATEThis 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_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><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

ParameterPossible ValuesDescription
ZOHO_CRITERIA
(optional)
CriteriaIf that parameter is not sent, then all the rows are updated. If criteria is sent the rows matching the criteria alone are updated.For more details about the format for the criteria view this link.
ZOHO_DATE_FORMAT
(optional)
Format of the date.
E.g. dd-MMM-YYYY
The format of date value. Specify this in-case any date field is being updated and its format cannot be auto recognized by Zoho Analytics.
ZOHO_VALID_JSON
(optional)
true / falseSpecific for JSON Response

By default it will be false.
True - Returns a valid JSON data (with JSON escaping) 
False - Returns a JSON data with JS escaping.

SPECIFYING THE DATA TO BE UPDATED (POST PARAMS)

Pass the columns whose values you would like to update in a <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 whose value is to be updated.

<value> - Refers to the corresponding value to be updated in the column

For specifying empty (null) values, the parameter should be sent with empty values. In the example above, the Deduction value is taken to be empty.

POSSIBLE ERROR CODES

7103 , 7138 , 7507 ,  8002 , 8004 , 8016 ,  8504 , 8506 , 8516 , 8533

Sample Request:

Copiedcurl -d "ZOHO_ACTION=UPDATE&ZOHO_OUTPUT_FORMAT=XML&ZOHO_ERROR_FORMAT=XML&ZOHO_API_VERSION=1.0&Name=as&ZOHO_CRITERIA=("Department" = 'Finance')" 
-H "Authorization:Zoho-oauthtoken <access_token>" https://analyticsapi.zoho.com/api/EmailAddress/WorkspaceName/TableName
Copied using ZReports;

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

        public void UpdateRow(IReportClient RepClient)
        {
            string tableURI = RepClient.GetURI(EMAIL, DBNAME, TBNAME);
            Dictionary<string, string> ColumnValues = new Dictionary<string, string>();
            ColumnValues.Add("Region", "North");
            string criteria = "\"Region\"='South'";
            RepClient.UpdateData(tableURI, ColumnValues, criteria, null);
        }

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

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

var (
	clientid      = "************"
	clientsecret  = "************"
	refreshtoken  = "************"
)

func updateData() {
	url := reportclient.GetUri("Email Address", "Workspace Name", "Table Name")
	params := map[string]string{}
	params["Salary"] = "100"
	params["ZOHO_CRITERIA"] = "Id=1"
	resp, err := reportclient.UpdateData(url, params)
	if err != nil {
		fmt.Println(err.ErrorMessage)
		fmt.Println(err.ErrorCode)
		fmt.Println(err.Action)
		fmt.Println(err.HttpStatusCode)
	} else {
		fmt.Println(resp)
	}
}

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

public class Sample {
    String clientId = "************";
    String clientSecret = "************";
    String refreshToken = "************";
    private ReportClient rc = new ReportClient(clientId, clientSecret, refreshToken);

    public void updateData() throws Exception {
        String uri = rc.getURI("Email Address", "Workspace Name", "Table Name");
        Map<String, Object> colval = new HashMap<>();
        colval.put("Salary", 1000);
        String criteria = "Age=55";
        Long result = rc.updateData(uri, colval, criteria, null);
        System.out.println(result);
    }

    public static void main(String[] args) throws Exception {
        Sample obj = new Sample();
        obj.updateData();
    }
}
Copied<?php
require 'ReportClient.php';
$CLIENT_ID = "************";
$CLIENT_SECRET = "************";
$REFRESH_TOKEN = "************";
$request = new ReportClient($CLIENT_ID, $CLIENT_SECRET, $REFRESH_TOKEN);
$uri = $request->getURI("Email Address", "Workspace Name", "Table Name");
$column_values = array("Salary" => "10000");
$criteria = "Experience = 2";
$resp = $request->updateData($uri, $column_values, $criteria);
print_r($resp);
?>
Copiedfrom __future__ import with_statement
from ReportClient import ReportClient
import sys

class Sample:
    CLIENTID = "************"
    CLIENTSECRET = "************"
    REFRESHTOKEN = "************"

    rc = None
    rc = ReportClient(REFRESHTOKEN, CLIENTID, CLIENTSECRET)

    def updateData(self, rc):
        uri = rc.getURI("Email Address", "Workspace Name", "Table Name")
        updateInfo = {"Region": "West", "Product": "SampleProduct_2"}
        criteria = "No=1000"
        result = rc.updateData(uri, updateInfo, criteria, None)
        print(result)

    obj = Sample()
    obj.updateData(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'] = 2;
    params['Gold'] = 6;
    params['ZOHO_CRITERIA'] = '\"Country\"=\'France\'';

    var uripath = nodelib.getUri(emailId, workspaceName, viewName);
    nodelib.updateData(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", "UPDATE");
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_CRITERIA", "");
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;

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

Sample Response:

Copied{"response":
    {"uri": "/api/EmailAddress/WorkspaceName/TableName",
        "action": "UPDATE",
        "criteria": "\"Department\" = 'Finance'",
        "result":
        {"updatedColumns":["Salary","Deduction","Perks"],
            "updatedRows":"4"}}}
Copied<?xml version="1.0"encoding="UTF-8" ?>
<responseuri="/api/EmailAddress/WorkspaceName/TableName"action="UPDATE">
    <criteria>"Department" = 'Finance'</criteria>
    <result>
        <updatedColumns>
            <column>Salary</column>
            <column>Deduction</column>
            <column>Perks</column>
        </updatedColumns>
        <updatedRows>4</updatedRows>
    </result>
</response>