简体   繁体   English

使用 Google Apps 脚本使用 People API 更新 Google 联系人照片

[英]Update google contact photo with People API using google apps script

I want to update a contact photo of my contacts using People API and google apps script.我想使用 People API 和 google 应用程序脚本更新我的联系人的联系人照片。 official document URL is here https://developers.google.com/people/api/rest/v1/people/updateContactPhoto官方文档网址在这里https://developers.google.com/people/api/rest/v1/people/updateContactPhoto

My Google Apps script code is below我的 Google Apps 脚本代码如下

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我收到此错误:对 people.people.updateContactPhoto 的 API 调用失败,错误为:空响应

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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM