Quantcast
Channel: Zoho Reports API
Viewing all articles
Browse latest Browse all 71

AddRow-java :: Version4.1

$
0
0

AddRow.java

The following is the sample code for adding a row to a table in a database in Zoho Reports. In this example a row is added to the table "Sales".

Before trying it out

public class AddRow { private ReportClient rc = null;
public void login() throws Exception { rc = Config.getReportClient(); System.out.println("Logging into the server"); rc.login(Config.LOGINNAME, Config.PASSWORD); System.out.println("Successfully logged in"); }

    public void addRow() throws Exception { String uri = rc.getURI(Config.LOGINNAME,Config.DATABASENAME,"Sales"); Map result = rc.addRow(uri,getRowValues(),null); System.out.println("Successfully added the row to " + uri); System.out.println(" The response is " + result); } 

   
public
void logout() throws Exception { rc.logout(); }

   
private static
HashMap getRowValues() { SimpleDateFormat dtFmt = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); HashMap rowValsMap = new HashMap(); rowValsMap.put("Date",dtFmt.format(new Date())); rowValsMap.put("Region","EAST"); rowValsMap.put("Product Category","Sample_Grocery"); rowValsMap.put("Product","Sample_Meat"); rowValsMap.put("Customer Name","John"); rowValsMap.put("Sales","2303"); rowValsMap.put("Cost","1000"); return rowValsMap; }

    public static
void main(String[] args) throws Exception { AddRow row = new AddRow(); //login
Once into the server row.login(); //call ADDROW API with the same logged in session row.addRow(); row.addRow(); //logout from the server row.logout(); } }

Viewing all articles
Browse latest Browse all 71

Trending Articles