I want to update a field in the Accounts module through API. But the problem is that When I update a field it updates successfully and it deletes the rest of the fields.
Which API are you using (v4.1 or v8)? And can you copy+paste your request here? But usually, you just provide those attributes that you want to set.
<?php
$url = "http://*instanceLink*/service/v4_1/rest.php";
function restRequest($method, $arguments){
global $url;
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$post = array(
"method" => $method,
"input_type" => "JSON",
"response_type" => "JSON",
"rest_data" => json_encode($arguments),
);
//print_r($post); die;
curl_setopt($curl, CURLOPT_POSTFIELDS, $post);
$result = curl_exec($curl);
// print_r($result);
return json_decode($result,1);
}
$userAuth = array(
'user_name' => 'username',
'password' => md5('password'),
);
$appName = 'suiteCrm';
$nameValueList = array("name"=>"hello","value"=>"test");
$args = array(
'user_auth' => $userAuth,
'application_name' => $appName,
'name_value_list' => $nameValueList);
$result = restRequest('login',$args);
$sessId = $result['id'];
$entryArgs = array(
'session' => $sessId,
'module_name' => 'Leads',
"name_value_list"=>array(array(
"id"=>$_POST['id'],
"first_name"=>$_POST['first_name'],
)
)
);
$result = restRequest('set_entry',$entryArgs);
print_r($result);
I want to update only the name field in the Leads module. It will successfully update first_name. But other fields will be erased.