Update google contacts Photo Using People API AND GOOGLE APPS SCRIPT

214 views
Skip to first unread message

Script stack

unread,
Jan 30, 2020, 3:14:52 AM1/30/20
to Google Apps Script Community

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


Andrew Apell

unread,
Jan 31, 2020, 1:23:27 PM1/31/20
to Google Apps Script Community
Where is "People" coming from?  People.People.updateContactPhoto(resourceName, reqBody)
Reply all
Reply to author
Forward
0 new messages