Open Activities - New Event - Zoho CRM API

348 views Asked by At

represents crm place for new event that I would like to create using codeI am trying to add New Event to Leads via API (Open Activities --- New Event, please see the images attached for references). I can create an event just but not Open Activities - New Event associated with Lead.

          //Initialize connection 
          $ch = curl_init('https://crm.zoho.com/crm/private/xml/Events/updateRecords?'); 
          // insertRecords instead updateRecords works fine but as informed before it creates only event just
          curl_setopt($ch, CURLOPT_VERBOSE, 1);//standard i/o streams 
          curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);// Turn off the server and peer verification 
          curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); 
          curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//Set to return data to string ($response) 
          curl_setopt($ch, CURLOPT_POST, 1);//Regular post 
          //Set post fields 
          //this script is being proccessed by a form so I also put all of my $_POST['name'] variable here to be 
          //used in the $xmlData variable below

          $authtoken = " f12ccd3daa030d2980b61d85d4824abf";
          $xml_data  = '<Events>'; 
            $xml_data .= '<row no="1">';
            $xml_data .= '<FL val="Subject">Subject of your choice</FL>';
            $xml_data .= '<FL val="Start DateTime">'.date('Y-m-d H:i:s').'</FL>';
            $xml_data .= '<FL val="End DateTime">'.date('Y-m-d H:i:s').'</FL>';
            $xml_data .= '<FL val="Venue">Mohanty</FL>';
            $xml_data .= '<FL val="Send Notification Email">false</FL>';
            $xml_data .= '</row>';
            $xml_data .= '</Events>';

          $query = "authtoken=$authtoken&scope=crmapi&newFormat=1&id=2739523000000127005&xmlData=$xml_data"; // id --- is the lead id
          curl_setopt($ch, CURLOPT_POSTFIELDS, $query);// Set the request as a POST FIELD for curl. 
          //Execute cUrl session 
          $response = curl_exec($ch); 
          print_r($response);
          curl_close($ch);
1

There are 1 answers

0
Nadeem Ahmad On
//Initialize connection 
          $ch = curl_init('https://crm.zoho.com/crm/private/xml/Events/insertRecords?'); 
          // insertRecords will only work to create events
          curl_setopt($ch, CURLOPT_VERBOSE, 1);//standard i/o streams 
          curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);// Turn off the server and peer verification 
          curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); 
          curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//Set to return data to string ($response) 
          curl_setopt($ch, CURLOPT_POST, 1);//Regular post 
          //Set post fields 
          //this script is being proccessed by a form so I also put all of my $_POST['name'] variable here to be 
          //used in the $xmlData variable below

          $authtoken = "your auth token";
          $xml_data  = '<Events>'; 
            $xml_data .= '<row no="1">';
            $xml_data .= '<FL val="Subject">Subject of your choice</FL>';
            $xml_data .= '<FL val="Start DateTime">'.date('Y-m-d H:i:s').'</FL>';
            $xml_data .= '<FL val="End DateTime">'.date('Y-m-d H:i:s').'</FL>';
            $xml_data .= '<FL val="Venue">Mohanty</FL>';
            $xml_data .= '<FL val="Send Notification Email">false</FL>';
            $xml_data .= '<FL val="SEMODULE">Leads</FL>'; // missing mapping module
            $xml_data .= '<FL val="SEID">LEAD ID</FL>'; // missing seid which is lead id
            $xml_data .= '</row>';
            $xml_data .= '</Events>';

          $query = "authtoken=$authtoken&scope=crmapi&newFormat=1&xmlData=$xml_data"; 
          curl_setopt($ch, CURLOPT_POSTFIELDS, $query);// Set the request as a POST FIELD for curl. 
          //Execute cUrl session 
          $response = curl_exec($ch); 
          print_r($response);
          curl_close($ch);

This will help in mapping and creating events.