Update Report API
The Update Report API in Zoho Analytics enables users to seamlessly update various reports. This API streamlines the process of modifying existing views, making it easier to analyze and present updated data.
REQUEST URI
https://<ZohoAnalytics_Server_URI>/restapi/v2/workspaces/<workspace-id>/reports/<report-id>
Put
oauthscope: ZohoAnalytics.modeling.update
QUERY PARAMETERS
| Description |
---|---|
CONFIG* | JSONObject Config parameter specifications are available in the below section. |
FIELDS FOR CONFIG JSON
Key | Description |
---|---|
title* | String Name of the report. |
description | String Description of the report. |
reportType* | String Accepted Values:
|
chartType | String Specifies the type of chart to be created. Accepted Values: Area Charts:
Bar Charts:
Bubble Charts:
Combo Charts:
Funnel and Pyramid Charts:
Line Charts:
Map Charts:
Pie and Ring Charts:
Scatter Charts:
Web Charts:
Heat Maps:
Other Charts:
|
axisColumns* | JSONArray Detailed information about the columns like type, column name, and functions applied over these columns in report. Check the table Axis Column Structure for more details. |
filters | JSONArray Detailed information about the filters like table name, column name, function applied, and filter type. Check the table Filter Structure for more details. |
userFilters | JSONArray Detailed information about the user filters like table name, column name, function applied, and filter type. Check the table User Filter Structure for more details. |
isAxisMerge | String Accepted Values:
|
mergeAxisInfo | String Note: mergeAxisInfo is available only if isAxisMerge is true. Sample: {"axisIndex":[2,3],"labelName":"Merge_axis"} |
AXIS COLUMN STRUCTURE ATTRIBUTE
Key | Description | ||||||||
type* | String Accepted Values:
| ||||||||
columnName* | String Name of the column used in the report. | ||||||||
operation* | String Accepted Values:
|
Key | Description | ||||||||||||||||||||||||||||||||||||||||||||||||
tableName* | String Name of the table used to create report. | ||||||||||||||||||||||||||||||||||||||||||||||||
columnName* | String Specifies the name of the column used in the filter. | ||||||||||||||||||||||||||||||||||||||||||||||||
operation* | String Accepted Values:
| ||||||||||||||||||||||||||||||||||||||||||||||||
filterType* | String Specifies the type of filter to be used in the report. Accepted values: individualValues, range, ranking, rankingPct, dateRange, year, quarterYear, monthYear, weekYear, quarter, month, week, weekDay, day, hour, dateTime Accepted values based on data type Numeric: individualValues, range, ranking, rankingPct Date: year, quarterYear, monthYear, weekYear, fullDate, dateTime, range, quarter, month, week, weekDay, day, hour, count, distinctCount | ||||||||||||||||||||||||||||||||||||||||||||||||
values* | JSONArray Specifies the array of values used in the specified filter. Sample: ["1000 to 2000", "3000 to 4000"] Accepted Values: Array of Values
| ||||||||||||||||||||||||||||||||||||||||||||||||
exclude* | String Indicates whether to include or exclude values for this filter. Accepted Values:
|
USER FILTER STRUCTURE ATTRIBUTE
Key | Description | ||||||||
tableName* | String Name of the table used to create report. | ||||||||
columnName* | String Specifies the name of the column used in the filter. | ||||||||
operation* | String Accepted Values:
|
POSSIBLE ERROR CODES
7138, 8092, 8144, 7301, 8021, 8145, 8050, 7725, 8052, 8053, 8059, 8056, 8093, 8094, 8095, 8096, 8097, 8099, 8100, 8101, 8054, 8055
Copiedcurl https://analyticsapi.zoho.com/restapi/v2/workspaces/<workspace-id>/reports/<view-id> --data-urlencode 'CONFIG={"reportType": "chart","axisColumns":[{"type":"xAxis","columnName":"Region","operation":"year"},{"type":"yAxis","columnName":"Sales","operation":"sum"}]}'
-X 'PUT'
-H 'ZANALYTICS-ORGID: <org-id>'
-H 'Authorization: Zoho-oauthtoken <access_token>'
Copiedusing System;
using System.Collections.Generic;
using ZohoAnalytics;
using System.Text.Json;
namespace ZohoAnalyticsTest
{
class Program
{
long orgId = 55522777;
long workspaceId = 35130000001055707;
public void UpdateReport(IAnalyticsClient ac)
{
long viewId = 35130000006291041;
Dictionary<string, object> config = new Dictionary<string, object>();
config.Add("reportType", "chart");
List<Dictionary<string, object>> axisColumns = new List<Dictionary<string, object>>();
Dictionary<string, object> xAxis = new Dictionary<string, object>();
xAxis.Add("type", "xAxis");
xAxis.Add("columnName", "Date");
xAxis.Add("operation", "year");
Dictionary<string, object> yAxis = new Dictionary<string, object>();
yAxis.Add("type", "yAxis");
yAxis.Add("columnName", "Cost");
yAxis.Add("operation", "sum");
axisColumns.Add(xAxis);
axisColumns.Add(yAxis);
config.Add("axisColumns", axisColumns);
IWorkspaceAPI ws = ac.GetWorkspaceInstance(orgId, workspaceId);
ws.UpdateReport(viewId, config);
Console.WriteLine("Success");
}
static void Main(string[] args)
{
string clientId = "1000.xxxxxxx";
string clientSecret = "xxxxxxx";
string refreshToken = "1000.xxxxxxx.xxxxxxx";
try
{
IAnalyticsClient ac = new AnalyticsClient(clientId, clientSecret, refreshToken);
Program obj = new Program();
obj.UpdateReport(ac);
}
catch (ServerException ex)
{
Console.WriteLine("Server exception - " + ex.GetErrorMessage());
}
catch (Exception ex)
{
Console.WriteLine("Other exception - " + ex.Message);
}
}
}
}
Copiedpackage main
import (
"fmt"
ZAnalytics "zoho/pkg/analyticsclient"
)
var(
clientId = "1000.xxxxxxx"
clientSecret = "xxxxxxx"
refreshToken = "1000.xxxxxxx.xxxxxxx"
orgId = "55522777"
workspaceId = "35130000001055707"
)
func UpdateReport(ac ZAnalytics.Client) {
viewid := "35130000006299001"
xaxis := map[string]interface{}{
"type": "xAxis",
"columnName": "Date",
"operation": "year",
}
yaxis := map[string]interface{}{
"type": "yAxis",
"columnName": "Cost",
"operation": "sum",
}
axiscolumns := []map[string]interface{}{xaxis, yaxis}
config := map[string]interface{}{
"reportType": "chart",
"axisColumns": axiscolumns,
}
workspace := ZAnalytics.GetWorkspaceInstance(&ac, orgId, workspaceId)
exception := workspace.UpdateReport(viewid, config)
if(exception != nil){
fmt.Println(exception.ErrorMessage)
}else{
fmt.Println("Success")
}
}
func main() {
ac := ZAnalytics.GetAnalyticsClient(clientId, clientSecret, refreshToken)
UpdateReport(ac)
}
Copiedimport com.zoho.analytics.client.*;
import org.json.*;
public class Test {
private long orgId = 55522777l;
private long workspaceId = 35130000001055707l;
public static void main(String args[]){
String clientId = "1000.xxxxxxx";
String clientSecret = "xxxxxxx";
String refreshToken = "1000.xxxxxxx.xxxxxxx";
Test tObj = new Test();
AnalyticsClient ac = new AnalyticsClient(clientId, clientSecret, refreshToken);
try {
tObj.updateReport(ac);
}
catch (ServerException ex) {
System.out.println("Server exception - ErrorCode : " + ex.getErrorCode() + ", ErrorMessage : " + ex.getErrorMessage());
}
catch (ParseException ex) {
System.out.println("Parser exception - ErrorMessage : " + ex.getResponseMessage());
}
catch (Exception ex) {
System.out.println("Other exception - ");
ex.printStackTrace();
}
}
public void updateReport(AnalyticsClient ac) throws Exception {
long viewId = 35130000005594013l;
JSONObject xAxis = new JSONObject();
xAxis.put("type", "xAxis");
xAxis.put("columnName", "Date");
xAxis.put("operation", "year");
JSONObject yAxis = new JSONObject();
yAxis.put("type", "yAxis");
yAxis.put("columnName", "Cost");
yAxis.put("operation", "sum");
JSONArray axisColumns = new JSONArray();
axisColumns.put(xAxis);
axisColumns.put(yAxis);
JSONObject config = new JSONObject();
config.put("reportType", "chart");
config.put("axisColumns", axisColumns);
WorkspaceAPI workspace = ac.getWorkspaceInstance(orgId, workspaceId);
workspace.updateReport(viewId, config);
System.out.println("success");
}
}
Copied<?php
require 'AnalyticsClient.php';
class Test
{
public $ac = NULL;
public $client_id = "1000.xxxxxxx";
public $client_secret = "xxxxxxx";
public $refresh_token = "1000.xxxxxxx.xxxxxxx";
public $org_id = "55522777";
public $workspace_id = "35130000001055707";
function __construct() {
$this->ac = new AnalyticsClient($this->client_id, $this->client_secret, $this->refresh_token);
}
function updateReport() {
$view_id = "35130000006310013";
$x_axis = [
"type" => "xAxis",
"columnName" => "Date",
"operation" => "year"
];
$y_axis = [
"type" => "yAxis",
"columnName" => "Cost",
"operation" => "sum"
];
$axis_columns = [$x_axis, $y_axis];
$config = [
"reportType" => "chart",
"axisColumns" => $axis_columns
];
$workspace = $this->ac->getWorkspaceInstance($this->org_id, $this->workspace_id);
$response = $workspace->updateReport($view_id, $config);
print_r($response);
}
}
$test_obj = new Test();
try {
$test_obj->updateReport();
}
catch(ServerException $se) {
echo "Server exception : " . $se->getErrorMessage() . "\n";
}
catch(IOException $ioe) {
echo "IO exception : " . $ioe->getErrorMessage() . "\n";
}
catch(ParseException $pe) {
echo "Parser exception : " . $pe->getErrorMessage() . "\n";
}
catch(Exception $e) {
echo "Exception : " . $e->getErrorMessage() . "\n";
}
?>
Copiedfrom __future__ import with_statement
from AnalyticsClient import AnalyticsClient
import sys
import json
class Config:
CLIENTID = "1000.xxxxxxx";
CLIENTSECRET = "xxxxxxx";
REFRESHTOKEN = "1000.xxxxxxx.xxxxxxx";
ORGID = "55522777";
WORKSPACEID = "35130000001055707";
class sample:
ac = AnalyticsClient(Config.CLIENTID, Config.CLIENTSECRET, Config.REFRESHTOKEN)
def update_report(self, ac):
view_id = "35130000006311001"
xaxis = {
"type": "xAxis",
"columnName": "Date",
"operation": "year"
}
yaxis = {
"type": "yAxis",
"columnName": "Cost",
"operation": "sum"
}
axis_columns = [xaxis, yaxis]
config = {
"reportType": "chart",
"axisColumns": axis_columns
}
workspace = ac.get_workspace_instance(Config.ORGID, Config.WORKSPACEID)
workspace.update_report(view_id, config)
print("success")
try:
obj = sample()
obj.update_report(obj.ac);
except Exception as e:
print(str(e))
Copiedvar analyticsClient = require('./AnalyticsClient');
const clientId = '1000.xxxxxxx';
const clientSecret = 'xxxxxxx';
const refreshToken = '1000.xxxxxxx.xxxxxxx';
const orgId = '55522777';
const workspaceId = '35130000001055707';
const ac = new analyticsClient(clientId, clientSecret, refreshToken);
const viewId = "35130000006310001";
const xaxis = {
type: "xAxis",
columnName: "Date",
operation: "year"
};
const yaxis = {
type: "yAxis",
columnName: "Cost",
operation: "sum"
};
const axisColumns = [xaxis, yaxis];
const config = {
reportType: "chart",
axisColumns: axisColumns
};
const workspace = ac.getWorkspaceInstance(orgId, workspaceId);
workspace.updateReport(viewId, config).catch((error) => {
console.log('errorCode: ' + error.errorCode);
console.log('errorMessage: ' + error.errorMessage);
});
CopiedorgId = "55522777";
workspaceId = "35130000001055707";
viewId = "35130000006310001";
headersMap = Map();
headersMap.put("ZANALYTICS-ORGID", orgId);
xAxis = Map();
xAxis.put("type", "xAxis");
xAxis.put("columnName", "Date");
xAxis.put("operation", "year");
yAxis = Map();
yAxis.put("type", "yAxis");
yAxis.put("columnName", "Cost");
yAxis.put("operation", "sum");
axisColumns = List();
axisColumns.add(xAxis);
axisColumns.add(yAxis);
config = Map();
config.put("reportType", "chart");
config.put("axisColumns", axisColumns);
paramsMap = Map();
paramsMap.put("CONFIG", config.toString());
response = invokeurl
[
url : "https://analyticsapi.zoho.com/restapi/v2/workspaces/" + workspaceId + "/reports/" + viewId
type :PUT
parameters: paramsMap
headers: headersMap
connection:"analytics_oauth_connection"
];
info response;
Download client SDKs : C# | GO | JAVA | PHP | PYTHON | NodeJS
Sample value for CONFIG parameter:
Copied{
"reportType": "chart",
"axisColumns": [
{
"type": "xAxis",
"columnName": "Region",
"operation": "year"
},
{
"type": "yAxis",
"columnName": "Sales",
"operation": "sum"
}
]
}
Sample Response:
CopiedHTTP/1.1 204 No Content