No properties found to update, please provide at least one.

I’m trying to use the code for the contact update using PHP integration but it is returning an error.

Error

No properties found to update, please provide at least one.

Here’s my code

$contactId = $searchResult['results'][0]['id'];
$properties = [
'properties' => [
'firstname' => $request['first_name'],
'lastname' => $request['last_name'],
'jobtitle' => $request['job_title'],
'email' => $request['email'],
'phone' => $request['phone']
]
];

$simplePublicObjectInput = new SimplePublicObjectInput($properties);

$client->crm()->contacts()->basicApi()->update($contactId, $simplePublicObjectInput);

Hello @jonjieviduya

The error message suggests that there are no properties provided for updating the contact. Make sure that the $request array contains values for at least one of the properties you’re trying to update (firstname, lastname, jobtitle, email, phone).

Also, you might want to check if the $contactId variable is set to a valid ID. You can add some error handling to verify that the search result returns at least one contact and that the ID is set correctly.

Here’s an example of how you can add some error handling to the code:

if (isset($searchResult['results'][0]['id'])) {
 $contactId = $searchResult['results'][0]['id'];

 $properties = [
 'properties' => [
 'firstname' => $request['first_name'],
 'lastname' => $request['last_name'],
 'jobtitle' => $request['job_title'],
 'email' => $request['email'],
 'phone' => $request['phone']
 ]
 ];

 $simplePublicObjectInput = new SimplePublicObjectInput($properties);

 $response = $client->crm()->contacts()->basicApi()->update($contactId, $simplePublicObjectInput);

 if ($response->getStatusCode() == 204) {
 echo "Contact updated successfully";
 } else {
 echo "Failed to update contact";
 }
} else {
 echo "Contact not found";
}

This code checks if the $contactId variable is set correctly and if the update operation was successful. It also provides some error messages to help you diagnose any issues.