I have done the following test with the latest API v3:
/civicrm/ajax/rest&json=1&debug=1&version=3&entity=Contact&action=update&id=1&gender_id=3
and get the following result:
{
"is_error":0,
"undefined_fields":["contact_id",
"gender",
"address_id",
"street_address",
"city",
"postal_code",
"state_province_id",
"state_province_name",
"state_province",
"country_id",
"country",
"phone_id",
"phone_type_id",
"phone",
"email_id",
"email",
"on_hold",
"worldregion_id",
"world_region",
"IDS_request_uri",
"IDS_user_agent",
"check_permissions",
"custom"],
"version":3,
"count":1,
"id":1,
"values":{
"1":
{
"id":"1",
"contact_type":"Individual",
"contact_sub_type":null,
"do_not_email":"0",
"do_not_phone":"0",
"do_not_mail":"0",
"do_not_sms":"0",
"do_not_trade":"0",
"is_opt_out":"0",
"legal_identifier":null,
"external_identifier":null,
"sort_name":"Hommel, Erik",
"display_name":"Erik Hommel",
"nick_name":null,
"legal_name":null,
"image_URL":"http:\/\/localhost\/core\/sites\/default\/files\/civicrm\/custom\/SDC10808_63e883d57c555f3c7dab75109dece7f3.JPG",
"preferred_communication_method":null,
"preferred_language":null,
"preferred_mail_format":"Both",
"hash":null,
"api_key":null,
"first_name":"Erik",
"middle_name":null,
"last_name":"Hommel",
"prefix_id":null,
"suffix_id":null,
"email_greeting_id":null,
"email_greeting_custom":null,
"email_greeting_display":null,
"postal_greeting_id":null,
"postal_greeting_custom":null,
"postal_greeting_display":null,
"addressee_id":null,
"addressee_custom":null,
"addressee_display":null,
"job_title":"partner",
"gender_id":"3",
"birth_date":"19630401000000",
"is_deceased":"0",
"deceased_date":null,
"household_name":null,
"primary_contact_id":null,
"organization_name":null,
"sic_code":null,
"user_unique_id":null
}
}
}
In a PHP call:
$params = array(
'id' => '1',
'gender_id' => '3',
'version' => '3');
$result = civicrm_api( 'Contact', 'Update', $params);
with result:
Array ( [is_error] => 0 [version] => 3 [count] => 1 [id] => 1 [values] => Array ( [1] => Array ( [id] => 1 [contact_type] => Individual [contact_sub_type] => [do_not_email] => 0 [do_not_phone] => 0 [do_not_mail] => 0 [do_not_sms] => 0 [do_not_trade] => 0 [is_opt_out] => 0 [legal_identifier] => [external_identifier] => [sort_name] => Hommel, Erik [display_name] => Erik Hommel [nick_name] => [legal_name] => [image_URL] => http://localhost/core/sites/default/files/civicrm/custom/SDC10808_63e883d57c555f3c7dab75109dece7f3.JPG [preferred_communication_method] => [preferred_language] => [preferred_mail_format] => Both [hash] => [api_key] => [first_name] => Erik [middle_name] => [last_name] => Hommel [prefix_id] => [suffix_id] => [email_greeting_id] => [email_greeting_custom] => [email_greeting_display] => [postal_greeting_id] => [postal_greeting_custom] => [postal_greeting_display] => [addressee_id] => [addressee_custom] => [addressee_display] => [job_title] => partner [gender_id] => 3 [birth_date] => 19630401000000 [is_deceased] => 0 [deceased_date] => [household_name] => [primary_contact_id] => [organization_name] => [sic_code] => [user_unique_id] => ) ) )
This does prove that I can update a contact without passing first name or last name. I will remove the civicrm_api3_contact_update function and close the issue.
Just a note on this
_civicrm_api3_contact_update
should be removed.
The correct call should be
civicrm_api('Contact','Update',$params);
We need a test to make sure this works