【发布时间】:2021-05-15 00:53:50
【问题描述】:
我正在尝试创建一个附加到电子表格的谷歌应用脚本,该电子表格可以设置谷歌用户的个人资料图片。根据文档,这应该可行:
var response = UrlFetchApp.fetch(url);
var photoBlob = response.getBlob();
var data = Utilities.base64EncodeWebSafe(photoBlob.getBytes());
AdminDirectory.Users.Photos.update({photoData: data}, this.email);
但是这会导致异常:
GoogleJsonResponseException: API call to directory.users.photos.update failed with error: Invalid Input: photoData
运行此脚本的用户有权编辑头像
【问题讨论】:
-
您是否确认您正确检索了 blob?请先尝试保存在云端硬盘中的照片。
标签: javascript google-apps-script google-api