Change Handlers Using REST API
SaveToDB 10 enables you to configure REST API services within a database, as detailed in Getting Data Using REST API and Saving Data Using REST API.
Here's a quick overview of the configuration:
ID | TABLE_SCHEMA | TABLE_NAME | TABLE_TYPE | TABLE_CODE | INSERT_OBJECT | UPDATE_OBJECT | DELETE_OBJECT |
---|---|---|---|---|---|---|---|
ZohoCRM | Contacts | HTTP | https://www.zohoapis.com/crm/v2/Contacts | POST {$url}
{"data":[{@json_row_values}]} | PUT {$url}/{id}
{"data":[{@json_row_values}]} | DELETE {$url}/{id} |
The configured ZohoCRM.Contacts
object shares the same configuration features as other native database objects.
Developers can set up change handlers using the xls.handlers table. Here’s an example:
ID | TABLE_SCHEMA | TABLE_NAME | COLUMN_NAME | EVENT_NAME | HANDLER_SCHEMA | HANDLER_NAME | HANDLER_TYPE | HANDLER_CODE |
---|---|---|---|---|---|---|---|---|
ZohoCRM | Contacts | First_Name | Change | HTTP | PUT https://www.zohoapis.com/crm/v2/Contacts/{id}
{"data":[{"First_Name":@First_Name}]} | |||
ZohoCRM | Contacts | Last_Name | Change | HTTP | PUT https://www.zohoapis.com/crm/v2/Contacts/{id}
{"data":[{"Last_Name":@Last_Name}]} |
The HANDLER_CODE
field contains the HTTP commands used to update a data source.
To use this method, the REST API must support updating individual fields. If it doesn't, you'll need to use the standard method for saving changes.
The URL can include parameters in curly brackets, like {id}
in the example above.
The add-in automatically populates these parameters from table columns and selects the appropriate URL parameters.
The request body can include parameters prefixed with the @
character.
For more details on the HTTP commands, check out: