diff --git a/htdocs/webservices/server_contact.php b/htdocs/webservices/server_contact.php index ec652e80074..e0d76a0eb90 100644 --- a/htdocs/webservices/server_contact.php +++ b/htdocs/webservices/server_contact.php @@ -627,9 +627,15 @@ function updateContact($authentication,$contact) $error=0; $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel); // Check parameters - if (empty($contact['id'])) { - $error++; $errorcode='KO'; $errorlabel="Contact id is mandatory."; + if (empty($contact['id']) && empty($contact['ref_ext']) { + $error++; $errorcode='KO'; $errorlabel="Contact id or ref_ext is mandatory."; } + // Check parameters + if (! $error && ($id && $ref_ext)) + { + $error++; + $errorcode='BAD_PARAMETERS'; $errorlabel="Parameter id and ref_ext can't be all provided. You must choose one of them."; + } if (! $error) { @@ -638,7 +644,7 @@ function updateContact($authentication,$contact) include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; $object=new Contact($db); - $result=$object->fetch($contact['id']); + $result=$object->fetch($contact['id'],0,$contact['ref_ext']); if (!empty($object->id)) {