google-people-api - 我在 Google People API 的 UpdateContactPhoto 和 deleteContactPhoto、createBatchContact 方法中遇到问题
问题描述
当我使用 UpdateContactPhoto 和 deleteContactPhoto google people API 时出现此错误
获取 updateContactPhoto、deleteContactPhoto 或 createBatchContact => TypeError: service.people.updateContactPhoto is not a function, TypeError: service.people.createBatchContact is not a function, TypeError: service.people.deleteContactPhoto is not a function 的错误。
API -
async updateContactPhoto(req, res) {
try {
let baseUrl = Buffer.from(req.body.photoUrl, 'utf8').toString('base64');
let auth = await this.authorize(req, res);
if (auth.credentials) {
let service = google.people({ version: "v1", auth: auth });
let data = await service.people.updateContactPhoto({
resourceName: req.body.resourceName,
requestBody: {
"photoBytes": baseUrl,
}
})
console.log("=========>>> ", data)
}
} catch (error) {
console.log("Error ===>>>> ", error)
}
}
API -
async createBatchContacts(req, res) {
try {
let auth = await this.authorize(req, res);
if (auth.credentials) {
const service = await google.people({ version: "v1", auth });
let batchContact = await service.people.batchCreateContacts({
requestBody: {
contacts: req.body.contacts,
readMask: ["addresses", "emailAddresses", "genders", "interests", "coverPhotos", "locales", "locations", "memberships", "metadata", "miscKeywords", "names", 'nicknames', "occupations", 'organizations', "phoneNumbers", "photos", "relations", 'sipAddresses', 'skills', "urls", "userDefined"],
}
})
console.log("RESULT ==>>>> ", batchContact)
}
} catch (error) {
console.log("Error ===>>>> ", error)
}
}
API -
async deleteContactPhoto(req, res) {
try {
let auth = await this.authorize(req, res);
if (auth.credentials) {
let service = await google.people({ version: "v1", auth });
let data = await service.people.deleteContactPhoto({
resourceName: req.body.resourceName,
})
console.log("=========>>> ", data)
}
} catch (error) {
console.log("Error ===>>>> ", error)
}
}
创建和更新联系人方法可以在相同的过程中正常工作,但在 updateContactPhoto、deleteContactPhoto 和 createBatchContact API 上出现错误。
解决方案
推荐阅读
- tfs - 如何在不签入的情况下将文件迁移到另一个分支?
- css - 如何使div的高度与显示器的高度匹配
- redirect - 通过应用程序负载平衡器的 http 到 https 重定向在 iphone safari 中不起作用
- office-js - 获取正文中文档属性的范围
- excel - 在 Excel 中将 Chr(10) 替换为 Chr(13) + Chr(10) 以导入 Access
- javascript - 摩卡测试失败的 assert.equal 相同的对象
- xml - Spring Batch StaxEventItemWriter 实际上没有写入文件
- android - 如何防止 ViewModel 被破坏
- python-3.x - 如何在 pandas DataFrame 中添加多个列名?
- javascript - 如何在 select 元素中获取选中项的 ID 文本?