1

in order to update my contacts phone numbers, I am using People API with following code:

function updateContact(contactRn, contactEtag, contactPhone){

  var bodyRequest = {
    "resourceName": contactRn,
    "etag": contactEtag,

    "phoneNumbers": [{
      'value': contactPhone,
      'Type': 'googleVoice' }]
   };
    
   People.People.updateContact(bodyRequest, contactRn, {updatePersonFields: "phoneNumbers"});
 }

It works. It updates the phone number of the contact.

Unfortunately, it also overwrites all other phone numbers associated with this contact, which means it deletes them.

Can you tell me how to update specific phone numbers only (like the contacts google voice number), using GAS?

Thanks, Flo

vasadia
  • 366
  • 5
  • 8
Flo
  • 11
  • 2
  • Have you tried using double-quote(") inside your phoneNumbers and "type" instead of 'Type'? – Jason E. Jun 28 '21 at 19:22
  • thanks for your hint, but this didn't solve the problem. The Documentation says: [All fields specified in the updateMask will be replaced.](https://developers.google.com/people/api/rest/v1/people/updateContact). to me updating single contact fields only seems to be not possible at the moment – Flo Jul 02 '21 at 13:15
  • did you managed to get this working? – Helio Borges Nov 04 '22 at 17:51

1 Answers1

0

Allright, I decided to try the simplest thing, and just add more itens to the array, and what you know? It worked for me.

        function updateContact(contactRn, contactEtag, contactPhone){
  var bodyRequest = {
    "resourceName": contactRn,
    "etag": contactEtag,
    "phoneNumbers": [{'value': contactPhone, 'type': 'googleVoice' },
    {'value': anotherPhone,'type': 'workphone' },
    {'value': thirdPhone,'type': 'homephone' }]
   };
    
   People.People.updateContact(bodyRequest, contactRn, {updatePersonFields: "phoneNumbers"});
 }

My contact now has updated all his 3 phone numbers on google contacts

Helio Borges
  • 122
  • 1
  • 8