API execution could result in Error conditions. In such cases, follow the below given steps to identify whether an error condition has occurred and to handle the same:
- Check the http response code. If it is 4xx or 5xx (eg., 400, 500, 401 etc.,), then it is an error.
- In case of error, the error information would be sent in the response body.
The format of the error content can be specified by the parameter ZOHO_ERROR_FORMAT. The value it can be either:
Sample Error Response
Below snippets provide a sample error response in XML and JSON formats when there is no such table called EmployeeDetails in EmployeeDB database.
<?xml version="1.0" encoding="UTF-8"?>
<response url="/api/demouser/EmployeeDB/EmployeeDetails" action="IMPORT">
<message>Table EmployeeDetails is not present in the database EmployeeDB</message>
"message": "Table EmployeeDetails is not present in the database EmployeeDB"