View Metadata

This API returns metadata of the given view identified by the URI.

REQUEST URI

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

Get

oauthscope: ZohoAnalytics.metadata.read

COMMON PARAMETERS

ParameterPossible ValuesDescription
ZOHO_ACTIONVIEWMETADATAThis parameter specifies the action to be performed by the API request.
ZOHO_OUTPUT_FORMATJSONThis parameter specifies the output format for the response.
ZOHO_ERROR_FORMATJSONSpecifies 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.

POSSIBLE ERROR CODES

7103 , 7104 , 7138 , 8504 , 8506 , 8516 , 8533

Sample Request:

Copiedcurl 
-d "ZOHO_ACTION=VIEWMETADATA&ZOHO_OUTPUT_FORMAT=JSON&ZOHO_API_VERSION=1.0&ZOHO_ERROR_FORMAT=JSON" 
-H "Authorization:Zoho-oauthtoken <access_token>" 
https://analyticsapi.zoho.com/api/EmailAddress/WorkspaceName/ViewName
Copiedusing ZReports;

namespace Test
{
    CLIENT_ID = "************";
    CLIENT_SECRET = "************";
    REFRESH_TOKEN = "************";
    EMAIL = "Email Address";
    DBNAME = "Workspace Name";
    VIEWNAME = "View Name";

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

        public void viewmetadata(IReportClient rc)
        {
            string uri = rc.GetURI(EMAIL, DBNAME, VIEWNAME);
            string result = rc.ViewMetadata(uri, null);
            Console.WriteLine(result);
        }

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

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

var (
	email      = "Email Address"
	dbname     = "Workspace Name"
	viewname   = "View Name"
	clientid   = "************"
	clientsecret = "************"
	refreshtoken = "************"
)

func viewmetadata() {
	url := reportclient.GetUri(email, dbname, viewname)
	params := map[string]string{}
	result, err := reportclient.ViewMetadata(url, params)
	if err != nil {
		fmt.Println(err.ErrorMessage)
		fmt.Println(err.ErrorCode)
		fmt.Println(err.Action)
		fmt.Println(err.HttpStatusCode)
	} else {
		fmt.Println(result)
	}
}

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

public class Sample {
    String email = "Email Address";
    String dbname = "Workspace Name";
    String viewname = "View Name";
    String clientId = "************";
    String clientSecret = "************";
    String refreshToken = "************";
    Map config = new HashMap();
    private ReportClient rc = new ReportClient(clientId, clientSecret, refreshToken);

    public void viewMetadata() throws Exception {
        String uri = rc.getURI(email, dbname, viewname);
        JSONObject result = rc.viewMetadata(uri, config);
        System.out.println(result);
    }

    public static void main(String[] args) throws Exception {
        Sample obj = new Sample();
        obj.viewMetadata();
    }
}
Copied<?php
require 'ReportClient.php';

$EMAIL_ID = "Email Address";
$WORKSPACE_NAME = "Workspace Name";
$VIEW_NAME = "View 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, $WORKSPACE_NAME, $VIEW_NAME);
$report_client_request->viewMetadata($uri);
?>
Copiedfrom __future__ import with_statement
from ReportClient import ReportClient
import sys

class Sample:
    LOGIN_EMAIL_ID = "Email Address"
    WORKSPACE_NAME = "Workspace Name"
    VIEW_NAME = "View Name"
    CLIENT_ID = "************"
    CLIENT_SECRET = "************"
    REFRESH_TOKEN = "************"
    rc = None
    rc = ReportClient(REFRESH_TOKEN, CLIENT_ID, CLIENT_SECRET)

    def viewMetadata(self, rc):
        uri = rc.getURI(self.LOGIN_EMAIL_ID, self.WORKSPACE_NAME, self.VIEW_NAME)
        try:
            result = rc.viewMetadata(uri)
            print(result)
        except Exception, e:
            print(str(e))

    obj = Sample()
    obj.viewMetadata(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 config = {};
    var uripath = nodelib.getUri(emailId, workspaceName, viewName);
    nodelib.viewMetadata(uripath, config).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", "VIEWMETADATA");
paramsMap.put("ZOHO_OUTPUT_FORMAT", "JSON");
paramsMap.put("ZOHO_ERROR_FORMAT", "JSON");
paramsMap.put("ZOHO_API_VERSION", "1.0");

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 for Table view type:

Copied{"response": {"uri": "/api/EmailAddress/WorkspaceName/ViewName",
        "action": "VIEWMETADATA",
        "result": {"viewInfo": {"viewId": "22222222222222",
                "viewName": "Table Name",
                "viewDesc": "View Desc",
                "viewType": "Table",
                "workspaceId": "9999999999999",
                "columnList": [{"columnId": "555555555555555",
                        "columnName": "Date",
                        "dataTypeId": 93,
                        "dataTypeName": "Date",
                        "columnIndex": 1,
                        "columnDesc": "",
                        "columnMaxSize": 19,
                        "isNullable": true,
                        "defaultValue": "",
                        "pkTableName": "",
                        "pkColumnName": "",
                        "formulaDisplayName": "",
                        "dateFormat": "dd MMMM, yyyy"},
                    {"columnId": "666666666666666",
                        "columnName": "Region",
                        "dataTypeId": 12,
                        "dataTypeName": "Plain Text",
                        "columnIndex": 2,
                        "columnDesc": "",
                        "columnMaxSize": 100,
                        "isNullable": true,
                        "defaultValue": "",
                        "pkTableName": "",
                        "pkColumnName": "",
                        "formulaDisplayName": ""}]}}}}

Sample Response for all other view types:

Copied{"response": {"uri": "/api/EmailAddress/WorkspaceName/ViewName",
        "action": "VIEWMETADATA",
        "result": {"viewInfo": {"viewId": "11111111111111",
                "viewName": "View Name",
                "viewDesc": "View Desc",
                "viewType": "Dashboard",
                "workspaceId": "9999999999999",
                "involvedViews": [{"viewId": "22222222222222",
                        "viewName": "View1",
                        "viewType": "Chart View"},
                    {"viewId": "33333333333333",
                        "viewName": "View2",
                        "viewType": "Query Table"}]}}}}