我想使用People API和google apps脚本更新联系人的联系人照片。官方文档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)
}
我收到此错误:对people.people.updateContactPhoto的API调用失败,并显示错误:空响应
答案 0 :(得分:2)
我更改了参数的位置,对我有用。
来自
var res = People.People.updateContactPhoto(resourceName, reqBody)
至
var res = People.People.updateContactPhoto(reqBody, resourceName)