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

Prerequisites :: Version14.1

$
0
0

Prerequisites for using the API

Users have to fullfill the below given prerequisites to use Zoho Reports API

1. It is mandatory to use HTTPS in all API requests instead of HTTP request. HTTP is not supported

2. Always use https://reportsapi.zoho.com as the API request URL.


Zoho Reports User Account

Users should have a valid Zoho Reports login id to use the API. If you do not have one, please Sign up into Zoho Reports and create a login

API key

In order to use the API, each third party application(/service) need to obtain an API key. We use the API key to track usage from the various applications(/services). The API key has to be passed as parameter in every API request/call made.

Click here to register for the API Key

Once we receive the request, we will send the API Key to the Email ID that you have specified during the registration process. Please do not distribute or use the key for creating multiple applications/services. You should request for an API key for each of your individual application(/service) that you plan to create. Any violations will result in the cancellation of the API Key.

Note: Getting the API Key is a one time process.

Ticket

Ticket is a session specific ID that is to be generated and passed along with every API call. To generate the ticket id, you have to send your authentication details (user name and password) to Zoho Accounts. It is equivalent to logging into Zoho Reports from browser.

How to generate a Ticket?
To generate a ticket for a particular user, you need to send an HTTPS POST to Zoho Accounts for user authentication. Here is a sample form post and the supported parameters :
<form method="POST" action="https://accounts.zoho.com/login" target="_self">
<input type="hidden" name="LOGIN_ID" value="[ZOHO Username or Email ID]">
<input type="hidden" name="PASSWORD" value="[Password for ZOHO ID]">
<input type="hidden" name="FROM_AGENT" value="true">
<input type="hidden" name="servicename" value="ZohoReports">
<input type="submit" value="Generate Ticket" class="divbutton" name="submit">
</form>
Here are the POST parameters that needs to supplied along with the Zoho account url : https://accounts.zoho.com/login.

Parameter Required Description
LOGIN_ID
Mandatory Zoho Username or Email ID of a particular user.
PASSWORD Mandatory
Password for the Zoho Username
FROM_AGENT
Mandatory
value should be always set to true
servicename
Mandatory
ZohoReports
Note : The parameter names passed in POST request are case-sensitive.
Response :

Depending on the parameters passed over the HTTPS POST request, you will get a response in the following name/value format:
#Thu Oct 26 02:17:49 PST 2009 
WARNING=
TICKET=543754375sdferuecmvc458545432dfffqq
RESULT=TRUE
Response Details:
  • #Comment -- Ticket generated date
  • WARNING -- If the parameters passed in the URL are incorrect, the user will get a warning message stating the same otherwise the value will be null.
  • TICKET -- Ticket generated for the request
  • RESULT -- Value is true if the ticket is generated successfully, else it is false.

After using the ticket in your application and if the ticket is not further needed in your application, then it is mandatory to invalidate the ticket (logout the session) using LOGOUT API which is discussed in the below topic.

   Important Notes:
  • Your API ticket is valid for 7 days. After 7th day, you must generate a new ticket to work with Zoho Reports - API service.
    If you are not updating the application with a new ticket ID, you will receive an "Invalid Ticket ID" error response from API request.
  • It is strongly recommended that you do not generate API ticket for every API request. You can use the same ticket in your application for 7 days without any issues.
  • You can only have a maximum of 20 concurrent API sessions

To Logout (Invalidate the ticket) from the session:

To logout (Invalidate the ticket) from the current session in your application, you need to send a HTTPS POST request as follows. It is mandatory to invalidate the ticket once the ticket usage is completed in the application.
<form method="POST" action="https://accounts.zoho.com/logout" target="_self">
<input type="hidden" name="ticket" value="ticket_value">
<input type="hidden" name="FROM_AGENT" value="true">
<input type="submit">
</form>
Note : The parameter names passed in POST request are case-sensitive.

Ticket Expiry:

The ticket that you generate will be valid for 7 days from the date on which it is generated. Subsequently, if you use the same Ticket in the API calls it will throw an error message. Hence you need to ensure you renew the ticket atleast once every 7 days in your application for using the Zoho Reports API. 

You can find out whether the ticket has expired through the following means
  • When you invoke any API through the old ticket it will throw an HTTP 400 error
  • The server will return a error response. The example format of the error message returned for a ADDROW api call is given below

Error Format is JSON
:
{
 
"response":{
   "uri":"/api/zoho_username/zoho_dbname/zoho_tablename",
   "action":"ADDROW",
   "error":{
     "code":8518,
     "message":"You need to (re)login to perform this operation"
   }
 }
}
Error Format is XML:
<response uri="/api/senthilvel.n/testingapi/testTable2" action="ADDROW">
      <error>
            <code>8518</code>
            <message>You need to (re)login to perform this operation</message>
      </error>
</response>


If you receive a error response like the above, parse the response to get the error code and check whether it is equal to the invalid ticket error code "8518" (or) "7309". This confirms that the Ticket has expired (session expired). You need to generate a new ticket by calling the Ticket generation API again to further call other Zoho Reports API methods.

We suggest you to parse the error response from our server and regenerate the ticket if  "invalid ticket" error thrown by our server (i.e in case of ticket expiry / session logged out).

Important Note:
  • You are strongly recommended not to generate API ticket for every API request. You can use the same ticket in your application for 7 days without any issues.

Database

To use the Zoho Reports API, users should have already created atleast a reporting database with required tables and reports in Zoho Reports service using the browser based Web interface provided. You cannot use the API, if there are no Databases available in your user account in Zoho Reports



Viewing all articles
Browse latest Browse all 71

Trending Articles