Delete Data
The data present in a table can be deleted using this API.
REQUEST URI
https://<ZohoAnalytics_Server_URI>/api/<OwnerEmail>/<WorkspaceName>/<TableName>
Post
oauthscope: ZohoAnalytics.data.delete
COMMON PARAMETERS
Parameter | Possible Values | Description |
---|---|---|
ZOHO_ACTION | DELETE | 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
Parameter | Possible Values | Description |
---|---|---|
ZOHO_CRITERIA (optional) | Criteria | If that parameter is not sent, then all the rows are deleted. If criteria is sent the rows matching the criteria alone are deleted.Please view this link for more details about the format for ZOHO_CRITERIA. |
ZOHO_VALID_JSON (optional) | true / false | Specific 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. |
ZOHO_CALLBACK_FUNCTION (optional) | Name of the json callback function | Specific for JSON Response Processes JSON response elsewhere in the JavaScript code on the page |
POSSIBLE ERROR CODES
Sample Request:
Copiedcurl -d "ZOHO_ACTION=DELETE&ZOHO_OUTPUT_FORMAT=XML&ZOHO_ERROR_FORMAT=XML
&ZOHO_API_VERSION=1.0
&ZOHO_CRITERIA=("Department" = 'Finance')"
-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 deleteRow(IReportClient RepClient)
{
string tableURI = RepClient.GetURI(EMAIL, DBNAME, TBNAME);
string criteria = "\"Region\"='South'";
RepClient.DeleteData(tableURI, criteria, null);
}
static void Main(string[] args)
{
Program obj = new Program();
IReportClient rc = obj.getClient();
obj.deleteRow(rc);
}
}
}
Copiedpackage main
import (
"fmt"
"zoho/pkg/reportclient"
)
var(
clientid = "************"
clientsecret = "************"
refreshtoken = "************"
)
func deletedata() {
url := reportclient.GetUri("Email Address", "Workspace Name", "Table Name")
params := map[string]string{}
params["ZOHO_CRITERIA"] = "Id=2"
resp,err := reportclient.DeleteData(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)
deletedata()
}
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 deletedata() throws Exception
{
String uri = rc.getURI("Email Address","Workspace Name","Table Name");
String criteria = "No=12";
Long result = rc.deleteData(uri,criteria,null);
System.out.println(result);
}
public static void main(String[] args) throws Exception
{
Sample obj = new Sample();
obj.deletedata();
}
}
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");
$criteria = "Experience = 3";
$resp = $request->deleteData($uri ,$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 DeleteData(self,rc):
uri = rc.getURI("Email Address","Workspace Name","Table Name")
criteria = "No=1001"
result = rc.deleteData(uri,criteria,None);
print result
obj = Sample()
obj.DeleteData(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['ZOHO_CRITERIA'] = '\"Country\"=\'France\'';
var uripath = nodelib.getUri(emailId, workspaceName, viewName);
nodelib.deleteData(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","DELETE");
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","");
response = invokeurl
[
url :"https://analyticsapi.zoho.com/api/" + email + "/" + workspaceName + "/" + viewName
type :POST
parameters:paramsMap
headers:headers
];
info response;
Sample Response:
Copied{
"response":
{
"uri": "/api/EmailAddress/WorkspaceName/TableName",
"action": "DELETE",
"criteria": "\"Department\" = \'Finance\'",
"result":
{
"message": "Deleted rows",
"deletedrows":"4"
}
}
}
Copied<?xml version="1.0" encoding="UTF-8" ?>
<response uri="/api/EmailAddress/WorkspaceName/TableName" action="DELETE">
<criteria>"Department" = 'Finance'</criteria>
<result>
<message>Deleted rows</message>
<deletedrows>4</deletedrows>
</result>
</response>