0
votes

I want to update a contact photo of my contacts using People API and google apps script. official document URL is here https://developers.google.com/people/api/rest/v1/people/updateContactPhoto

My Google Apps script code is below

function imageUpdate(){
  var id = 'c6379259805458445151'
  var url = 'https://admin.singlaapparels.com/Main/fileurl/64F619B8-C2BE-4EDF-BF9B-01FD60C5D957/4/RakeshKumar.jpg'
  var blob = UrlFetchApp.fetch(url).getBlob();
  var data = Utilities.base64EncodeWebSafe(blob.getBytes());
  var resourceName = 'people/'+id;
  Logger.log(data)
  var reqBody = {
    "photoBytes": data,
    "personFields": "photos"
  }
var res = People.People.updateContactPhoto(resourceName, reqBody)
Logger.log(res)   
}

I got this error: API call to people.people.updateContactPhoto failed with error: Empty response

1

1 Answers

2
votes

I change the position of parameters and It works for me.

from

var res = People.People.updateContactPhoto(resourceName, reqBody)

to

var res = People.People.updateContactPhoto(reqBody, resourceName)