使用 google 应用程序脚本更新 google 与人物 API 的联系人照片
Update google contact photo with People API using google apps script
我想使用 People API 和 google 应用程序脚本更新我联系人的联系人照片。官方文档URL在这里https://developers.google.com/people/api/rest/v1/people/updateContactPhoto
我的 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)
}
我收到此错误:API 调用 people.people.updateContactPhoto 失败,错误为:空响应
我改变了参数的位置,它对我有用。
来自
var res = People.People.updateContactPhoto(resourceName, reqBody)
至
var res = People.People.updateContactPhoto(reqBody, resourceName)
我想使用 People API 和 google 应用程序脚本更新我联系人的联系人照片。官方文档URL在这里https://developers.google.com/people/api/rest/v1/people/updateContactPhoto
我的 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)
}
我收到此错误:API 调用 people.people.updateContactPhoto 失败,错误为:空响应
我改变了参数的位置,它对我有用。
来自
var res = People.People.updateContactPhoto(resourceName, reqBody)
至
var res = People.People.updateContactPhoto(reqBody, resourceName)