Here we learn How to update record in ZOHO modules using Curl request.
Update Record In Zoho Module
Before making the api call to records with the rest apis we need to follow some Steps.
1: To generate the Auth Token, you need to follow Below URL.
https://www.thecodehubs.com/generate-access-code-using-postman-for-zoho
2: Create zoho-update.php file to update record in module and put below code in this file.
Request URL:
https://www.zohoapis.com/crm/v2/{module_name}
Where,
Module_name: The API name of the module
Possible_Module_name: leads, accounts, contacts, deals, campaigns, tasks, cases, events, calls, solutions, products, vendors, pricebooks, quotes, salesorders, purchaseorders, invoices, custom, and notes.
<?php $header = array( 'Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf" ); $data = array( 'data' => array( array( "id": "554023000000527002", "Company": "testing-company", "State":"Testing" ), ), 'trigger' => array(), ); $data_json = json_encode($data); $ch = curl_init(); curl_setopt( $ch, CURLOPT_URL, "https://www.zohoapis.com/crm/v2/{Module_name}"); curl_setopt( $curl, CURLOPT_HTTPHEADER, $header ); curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, "PUT" ); curl_setopt( $ch, CURLOPT_POSTFIELDS, $data_json ); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); $response = curl_exec($ch); curl_close($ch); ?>
Here response look like as,
Now we learn how to update specific record using curl request.
Update Specific Record In Zoho Module
Request URL:
https://www.zohoapis.com/crm/v2/{Module_name}/{record_id}
Where,
Module_name : The API name of the module
record_id : Specific Record id which you want to update.
<?php $header = array( 'Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf" ); $data = array( 'data' => array( array( "id": "554023000000527002", "Company": "testing-company", "State":"tseting" ), ), 'trigger' => array(), ); $data_json = json_encode($data); $ch = curl_init(); curl_setopt( $ch, CURLOPT_URL, "https://www.zohoapis.com/crm/v2/{Module_name}/{record_id}"); curl_setopt( $curl, CURLOPT_HTTPHEADER, $header ); curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, "PUT" ); curl_setopt( $ch, CURLOPT_POSTFIELDS, $data_json ); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); $response = curl_exec($ch); curl_close($ch); ?>
How to insert or update Record
The system checks for duplicate records based on the duplicate check field’s values. If the record is already present, it gets updated. If not, the record is inserted. Add below code in your file to add or update record.
Here,
Request URL:
https://www.zohoapis.com/crm/v2/{module_name}
Where,
module_name : The API name of the module
<?php $header = array( 'Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf" ); $data = array( 'data' => array( array( "id": "554023000000527002", "Company": "tseting-company", "State":"test" ), ), 'duplicate_check_fields' => array( "Email", "Mobile" ), 'trigger' => array(), ); $data_json = json_encode($data); $ch = curl_init(); curl_setopt( $ch, CURLOPT_URL, "https://www.zohoapis.com/crm/v2/{Module_name}/upsert"); curl_setopt( $curl, CURLOPT_HTTPHEADER, $header ); curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, "PUT" ); curl_setopt( $ch, CURLOPT_POSTFIELDS, $data_json ); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); $response = curl_exec($ch); curl_close($ch); ?>