C# Library
The C# client libraries wraps the raw HTTP based API of Zoho Reports with easy to use methods for the C# .Net platform. This enables C# .Net developers to easily use Zoho Reports API.Prerequisites:
It is recommend to go through the Zoho Reports API Documentation and the Prerequisites before using the C# client library code in your application.
Download C# Client Library:
Download the C# client library (dll) from the following links.
- ZohoReports.dll (32-bit)
- ZohoReports.dll (64-bit)
Add reference to your C# Projects using these .dll files. With this you will be able to perform Zoho Reports API operations using the available functions.
Methods Summary:
C# .Net developers need to create a ReportClient object to access the below functions. The sample code snippet is below.- string userEmailId - The Primary Email Address of your Zoho Reports Account
- string AdminEmailId - The Primary Email Address of your Zoho Reports Account.
- string DatabaseName - The Zoho Reports Database Name
- string AdminEmailId - The Primary Email Address of your Zoho Reports Account.
- string DatabaseName - The Zoho Reports Database Name
- string ViewName - The Zoho Reports View Name. This could be a chart, pivot table, summary view, table, query table or dashboard created in Zoho Reports.
- string TableURI - The URI of the Table, into which the data has to be imported, got from the GetURI function
- string ImportType - The Import Type for the import process. This can be taken from ZohoReportsConstants file (which has all the constant variables used in this Library).
- string CSVFilePath - The file path of your data file
- Dictionary ImportConfig - This parameter holds the import parameters such as ZOHO_ON_IMPORT_ERROR, ZOHO_DATE_FORMAT, etc. You can check out the list of import parameters here.
- string TableURI - The URI of the table, into which the data is to be added, got from the GetURI function
- Dictionary ColumnValues - The Dictionary of Column Names and Values. The Values are added to the respective columns specified in the columnValues Dictionary.
- Dictionary Config - The Dictionary for sending extra parameters, if any.
- string TableURI - The URI of the table, in which the data is to be updated, got from the GetURI function
- Dictionary ColumnValues - The Dictionary of Column Names and Values. The Values are updated to the respective columns specified in the columnValues Dictionary.
- string Criteria - Criteria for updating rows. The rows matching the specified criteria alone will get updated. The criteria follows the SQL SELECT WHERE condition like format. More details on specifying Zoho Criteria is available in Applying Filters section.
- Dictionary Config - The Dictionary for sending extra parameters, if any.
- string TableURI - The URI of the table, in which the data is to be deleted, got from the GetURI function
- string Criteria - Criteria for deleting rows. The rows matching the specified criteria alone will get deleted. The criteria follows the SQL SELECT WHERE condition like format. More details on specifying Zoho Criteria is available in Applying Filters section.
- Dictionary Config - The Dictionary for sending extra parameters, if any.
- string ViewURI - The URI of the view, from which the data is to be exported, got from the GetURI function
- string Criteria - Criteria for exporting data. The rows matching the specified criteria alone will get exported. The criteria follows the SQL SELECT WHERE condition like format. More details on specifying Zoho Criteria is available in Applying Filters section.
- Dictionary Config - The Dictionary for sending extra parameters, if any.
- string ViewURI - The URI of the view, from which the data is to be exported, got from the GetURI function
- string Criteria - Criteria for exporting data. The rows matching the specified criteria alone will get exported. The criteria follows the SQL SELECT WHERE condition like format. More details on specifying Zoho Criteria is available in Applying Filters section.
- Dictionary Config - The Dictionary for sending extra parameters, if any.
- string ViewURI - The URI of the view, from which the data is to be exported, got from the GetURI function
- string Format - The output format for exporting the data. The supported formats are CSV, XML, JSON, HTML, PDF, IMAGE.
- string OutputFileName - The data will be exported to the specified output file in the local machine.
- string Criteria - Criteria for exporting data. The rows matching the specified criteria alone will get exported. The criteria follows the SQL SELECT WHERE condition like format. More details on specifying Zoho Criteria is available in Applying Filters section.
- Dictionary Config - The Dictionary for sending extra parameters, if any.
- string ViewURI - The URI of the view, from which the data is to be exported, got from the GetURI function
- string Format - The output format for exporting the data. The supported formats are CSV, XML, JSON, HTML, PDF, IMAGE.
- Stream OutputStream - The output stream to which the data has to be exported.
- string Criteria - Criteria for exporting data. The rows matching the specified criteria alone will get exported. The criteria follows the SQL SELECT WHERE condition like format. More details on specifying Zoho Criteria is available in Applying Filters section.
- Dictionary Config - The Dictionary for sending extra parameters, if any.
- string ViewURI - The URI of the view, from which the data is to be exported, got from the GetURI function
- string Criteria - Criteria for exporting data. The rows matching the specified criteria alone will get exported. The criteria follows the SQL SELECT WHERE condition like format. More details on specifying Zoho Criteria is available in Applying Filters section.
- Dictionary Config - The Dictionary for sending extra parameters, if any.
Key<string>: column_order
Value<Object[]>: ["column1","column2",..,"columnN"]
Key<string>: rows
Value<Object[]>: [ [value11,value12,..,value1N],[value21,valuu22,..,value2N] ]
- string ViewURI - The URI of the view, from which the data is to be exported, got from the GetURI function
- string Format - The output format for exporting the data. The supported formats are CSV, XML, JSON, HTML, PDF, IMAGE.
- string OutputFileName - The data will be exported to the specified output file in the local machine
- string SQLQuery - The SQL SELECT Query which has to be executed to fetch the result set that is to be executed
- Dictionary Config - The Dictionary for sending extra parameters, if any.
- string ViewURI - The URI of the view, from which the data is to be exported, got from the GetURI function
- string Format - The output format for exporting the data. The supported formats are CSV, XML, JSON, HTML, PDF, IMAGE.
- Stream OutputStream - The output stream to which the data has to be exported.
- string SQLQuery - The SQL SELECT Query which has to be executed to fetch the result set that is to be executed
- Dictionary Config - The Dictionary for sending extra parameters, if any.
- string DatabaseURI - The corresponding Zoho Reports Database URI got from the GetURI function
- string MetaData - The metadata type which can be got from ZohoReportsConstants file.
- string format - The response format for the metadata. The supported formats are XML and JSON.
- Dictionary Config - The Dictionary for sending extra parameters, if any.
- string DatabaseURI - The corresponding Zoho Reports Database URI got from the GetURI function
- Dictionary Config - The Dictionary for sending extra parameters, if any.
- string DatabaseURI - The URI of the Zoho Reports Database to be copied, got from the GetURI function
- string NewDBName - The Database Name for the newly copied database
- string NewDBDescription - The Description for the newly copied database
- bool WithData - If true, the database will be copied along with data, else the database will be copied without data
- Dictionary Config - The Dictionary for sending extra parameters, if any.
- string AccountURI - Your Zoho Reports Account URI got from the GetURI function
- string DatabaseName - The name of the database to be deleted
- string AccountURI - Your Zoho Reports AccountURI got from GetURI function
- string EmailIds - The Zoho primary email addresses of the users to be added, separated by comma (,)
- Dictionary Config - The Dictionary for sending extra parameters, if any.
- string AccountURI - Your Zoho Reports AccountURI got from GetURI function
- string EmailIds - The Zoho primary email addresses of the users to be removed, separated by comma (,)
- Dictionary Config - The Dictionary for sending extra parameters, if any.
- string AccountURI - Your Zoho Reports AccountURI got from GetURI function
- string EmailIds - The Zoho primary email addresses of the users to be activated, separated by comma (,)
- Dictionary Config - The Dictionary for sending extra parameters, if any.
- string AccountURI - Your Zoho Reports AccountURI got from GetURI function
- string EmailIds - The Zoho primary email addresses of the users to be de-activated, separated by comma (,)
- Dictionary Config - The Dictionary for sending extra parameters, if any.
- string host - The host name or IP Address of your proxy host
- int port - The port number for connecting your proxy
- string user - The username for authenticating to your proxy
- string password - The password for authenticating to your proxy
- ZOHO_CATALOG_LIST - To list the Zoho Reports databases for the specified user
- ZOHO_CATALAOG_INFO - To fetch information about the tables & reports (view) present in the given reporting database in Zoho Reports.
- ZOHO_DATATYPES - To get the list of datatypes supported by Zoho Reports
- ZOHO_TABLETYPES - Various view types available in Zoho Reports
- APPEND - Appends the data into the table
- TRUNCATEADD - Deletes all existing rows in the table and adds the imported data as a new entry
- UPDATEADD - Updates the row if the mentioned column values (in ZOHO_MATCHING_COLUMNS parameter) are matched, else a new entry will be added
Sample Program:
The below sample program illustrates how to invoke Zoho Reports API using Zoho Reports C# client library.The program steps are classified as follow.
- Creating ReportClient object
- Import API
- Add Row API
- Update Row API
- Delete Row API
- Export API
- Calling API functions from Main function
using System; using System.Collections.Generic; using System.Linq; using System.Text; using ZReports; // Namespace which contains classes for invoking Zoho Reports APIs namespace MyZohoReportsClient { class MyJob { /* Creating ReportClient object for invoking Zoho Reports APIs */ public IReportClient getClient() { // Creating ReportClient Object using Auth Token // ReportClient class contains all the supported API operations as functions IReportClient RepClient = new ReportClient("---your_authtoken_here---"); return RepClient; } /* The following method uses Zoho Reports IMPORT API to import the data from a local file into Zoho Reports Table. This method illustrates importing data from the location "C:\workspace\mydata.csv" into the table named "MyTable1" in "MyDB" reporting database. The usage of Import API is described below. IMPORT API: The IMPORT API allows you to import the data from your local file into Zoho Reports Table. Zoho Reports C# Library Function: ImportData(string tableURI, string ImportType, string FilePath, Dictionary<string,string> ImportConfig) Parameters: string tableURI This is the URI for the Zoho Reports Table into which the data has to be imported. Get the tableURI from GetURI(emailId,databaseName,tableName) function. The GetURI function will get your email address, the Zoho Reports Database Name and Zoho Reports Table Name as parameters. string ImportType This specifies how to import data. The Import type parameter can be set to APPEND, TRUNCATEADD or UPDATEADD. These constants can be set from ZohoReportsConstants class To know more about the Import Types, refer the Zoho Reports Import API Parameters section. string FilePath The location of the file which needs to be imported into Zoho Reports. The Import API will read the data from the file specified in this parameter and uploads the same into Zoho Reports Table. Dictionary<string,string> ImportConfig Dictionary to specify the additional Import Parameters. This Dictionary has the Parameter Name as Key and Parameter Value as Value. This ImportData function returns the Import Summary as a Dictionary */ public void importData(IReportClient RepClient) { string tableURI = RepClient.GetURI("testuser@zoho.com", "MyDB", "MyTable1"); Dictionary<string, string> ImportConfig = new Dictionary<string, string>(); ImportConfig.Add("ZOHO_ON_IMPORT_ERROR", "ABORT"); Dictionary<string, string> ImportRes = RepClient.ImportData(tableURI, ZohoReportsConstants.APPEND, "C:\\workspace\\mydata.csv",ImportConfig); } /* The following method uses Zoho Reports ADDROW API to add a single row into the Zoho Reports Table. This method illustrates adding a single row to the table "MyTable1" in "MyDB" database. This table consists of a single column named "Region" The usage of AddRow API is described below. ADDROW API: The ADDROW API allows you to add a single row into the specified Zoho Reports table. Zoho Reports C# Library Function: AddRow(string tableURI,Dictionary<string,string> ColumnValues,Dictionary<string,string> Config) Parameters: string tableURI This is the URI for the Zoho Reports Table into which the data has to be imported. Get the tableURI from GetURI(emailId,databaseName,tableName) function. The GetURI function will get your email address, the Zoho Reports Database Name and Zoho Reports Table Name as parameters. Dictionary<string,string> ColumnValues The Dictionary which has Zoho Reports Table Column Name as Key and Column Value as Value. All the entries in the ColumnValues Dictionary will be added as a Row in the specified table in the tableURI Dictionary<string,string> Config Useful for sending additional parameters, if any. This Dictionary has the Parameter Name as Key and Parameter Value as Value. This AddRow function returns the added values as a Column Name vs. Column Value Dictionary */ public void addRow(IReportClient RepClient) { string tableURI = RepClient.GetURI("testuser@zoho.com", "MyDB", "MyTable1"); Dictionary<string, string> ColumnValues = new Dictionary<string, string>(); ColumnValues.Add("Region", "South"); Dictionary<string, string> addRowRes = RepClient.AddRow(tableURI, ColumnValues, config); } /* The following method uses Zoho Reports UPDATE API to update rows in Zoho Reports Table. This method illustrates updating the value 'South' with 'North' for the column "Region" in the Zoho Reports table "MyTable1" in "MyDB" database. The usage of UpdateData API is described below. UPDATE API: The data present in a Zoho Reports Table can be updated using Zoho Reports UPDATE API. Zoho Reports C# Library Function: UpdateData(string tableURI, Dictionary<string,string> ColumnValues, string criteria, Dictionary<string,string> Config) Parameters: string tableURI This is the URI for the Zoho Reports Table into which the data has to be updated. Get the tableURI from GetURI(emailId,databaseName,tableName) function. The GetURI function will get your email address, the Zoho Reports Database Name and Zoho Reports Table Name as parameters. Dictionary<string,string> ColumnValues The Dictionary which has Zoho Reports Table Column Name as Key and Column Value as Value. All the entries in the ColumnValues Dictionary will be updated in the specified table in the tableURI string criteria Criteria for updating data. The rows matching this criteria alone will get updated. The criteria should follow the same format as that of the SQL WHERE clause. To know more about specifying criteria, refer the Applying Filters section in Zoho Reports API Documentation. Dictionary<string,string> Config Useful for sending additional parameters, if any. This Dictionary has the Parameter Name as Key and Parameter Value as Value. This UpdateData function will not return any object. */ public void updateRow(IReportClient RepClient) { string tableURI = RepClient.GetURI("testuser@zoho.com", "MyDB", "MyTable1"); Dictionary<string, string> ColumnValues = new Dictionary<string, string>(); ColumnValues.Add("Region", "North"); string criteria = "\"Region\"='South'"; RepClient.UpdateData(tableURI, ColumnValues, criteria, null); } /* The below method uses Zoho Reports DELETE API to delete rows in Zoho Reports Table. In this method, the rows matching value 'South' in column Region is deleted from the table MyTable1 in MyDB database. The usage of DeleteData API is described below. DELETE API: The data present in a Zoho Reports Table can be deleted using Zoho Reports DELETE API. Zoho Reports C# Library Function: DeleteData(string tableURI, string criteria, Dictionary<string,string> Config) Parameters: string tableURI This is the URI for the Zoho Reports Table into which the data has to be deleted. Get the tableURI from GetURI(emailId,databaseName,tableName) function. The GetURI function will get your email address, the Zoho Reports Database Name and Zoho Reports Table Name as parameters. string criteria Criteria for deleting data. The rows matching this criteria alone will get deleted. The criteria should follow the same format as that of the SQL WHERE clause. To know more about specifying criteria, refer to the Applying Filters section in Zoho Reports API Documentation. Dictionary<string,string> Config Useful for sending additional parameters, if any. This Dictionary has the Parameter Name as Key and Parameter Value as Value. This DeleteData function will not return any object. */ public void deleteRow(IReportClient RepClient) { string tableURI = RepClient.GetURI("testuser@zoho.com", "MyDB", "MyTable1"); string criteria = "\"Region\"='South'"; RepClient.DeleteData(tableURI, criteria, null); } /* The following method uses Zoho Reports EXPORT API to Export data from a Zoho Reports Table or Report. This method illustrates exporting the data matching value 'West' in column "Region" from the Zoho Reports Table "MyTable1" in "MyDB" database. The usage of Export API is described below. EXPORT API: The data present in a Zoho Reports Table or Report can be exported using Zoho Reports EXPORT API. Zoho Reports C# Library Function: ExportDataAsObject(string tableOrReportURI, string criteria, Dictionary<string,string> Config) Parameters: string tableOrReportURI This is the URI for the Zoho Reports Table or Report from which the data has to be exported. Get the tableOrReportURI from GetURI(emailId,databaseName,tableNameOrReportName) function. The GetURI function will get your email address, the Zoho Reports Database Name and Zoho Reports Table Name as parameters. string criteria Criteria for exporting data. The rows matching this criteria alone will get exported. The criteria should follow the same format as that of the SQL WHERE clause. To know more about specifying criteria, refer to the Applying Filters section in Zoho Reports API Documentation. Dictionary<string,string> Config Useful for sending additional parameters, if any. This Dictionary has the Parameter Name as Key and Parameter Value as Value. This ExportDataAsObject function will return an object which can be iterated to get the result. */ public object export(IReportClient RepClient) { string tableURI = RepClient.GetURI("testuser@zoho.com", "MyDB", "MyTable1"); Dictionary<string, object> resObj = RepClient.ExportDataAsDictionary(tableURI, "\"Region\"='West'", null);
Object[] columns = (Object[])resObj["column_order"];
Object[] rows = (Object[])resObj["rows"];
} public static void Main(string[] s) { MyJob myJob = new MyJob(); IReportClient rc = myJob.getClient(); myJob.importData(rc); myJob.addRow(rc); myJob.updateRow(rc); myJob.deleteRow(rc); myJob.export(rc); Console.Read(); } } }