I´m trying to update existing contact using People service from Google apps gs. I have a contact like this:
let contactInfo = {
"name" : "Jhon",
"lastName": "Doe",
"phone": "+1999999",
"rn": "people/c8289118840931811524",
"etag": "%EgkBAj0JPgs/Ny4aBAECBQciDDV1TzVFdXY0ckhnPQ=="
}
I created the folowing function in order to update contact more easily:
function updateContact(contactInfo){
//var updatePersonFields = "updatePersonFields=names,phoneNumbers,emailAddresses";
var bodyRequest = {
"resourceName": contactInfo.rn,
"etag": contactInfo.etag,
"names": [{
"givenName": contactInfo.name,
"familyName": contactInfo.lastName,
}],
"phoneNumbers": [{
'value': contactInfo.phone
}],
"emailAddresses": [{
'value': contactInfo.email
}]
};
People.People.updateContact(bodyRequest, contactInfo.rn);
}
However, the document guide for updateContact needs 3 parameters: Path parameters, Query Parameters and request body: https://developers.google.com/people/api/rest/v1/people/updateContact
In order to update contact, I have to pass updatePersonfields, but it is a Query Parameter and the updateContact just only receive 2 parameters.
I know that etag and updatePersonfields is needed, as the link explain it: https://developers.google.com/people/v1/contacts?hl=en#update_an_existing_contact
How can I add the Query Parameter updatePersonFields (in comments)?
If updatePersonField is not send it, I have the following error:
GoogleJsonResponseException: API call to people.people.updateContact failed with error:
updatePersonFields mask is required. Please specify one or more valid paths.
Valid paths are documented at
https://developers.google.com/people/api/rest/v1/people/updateContact.
Thanks you in advanced.