即使过去一年多次提出此问题,但尚未正确解决...尤其是在使用最新的googleapis lib时!谷歌文档没有用,因为仍然提到许多弃用的方法,并且没有给出javascript示例...
使用people.get()(在list()之后)我可以查看它应该如何(我猜)
jsonPayload
所以我尝试用这种方式创建一个新人:
{
"resourceName":"people/c3451490284670017263",
"etag":"%EgcBAggJNyUuGgwBAgMEBQYHCAkKCwwiDHVtR0Y5OHZVMnhJPQ==",
"locales":[{"metadata":{"primary":true,"source":{"type":"CONTACT","id":"2fe628208b77deef"}},"value":"en"}],
"emailAddresses":[{"metadata":{"primary":true,"source":{"type":"CONTACT","id":"2fe628208b77deef"}},"value":"john.doe@example.com"]
}
但没有办法......我总是遇到错误:
return google.people('v1').people.createContact({
auth: jwtClient,
resourceName: 'people/me',
locales: ['en'],
genders: ['female'],
names: [{givenName: 'Jenny', familyName: 'Doe'}],
emailAddresses: ['jenny.doe@example.com']
})
网上是否存在任何示例?
反馈欢迎......(即使是谷歌男子...... LOL)
答案 0 :(得分:1)
在仔细检查(可能是三倍......)文档之后,我阅读了following statement
Usage
Specifying request body
The body of the request is specified in the requestBody parameter object of the request. The body is specified as a JavaScript object with key/value pairs. For example, this sample creates a watcher that posts notifications to a Google Cloud Pub/Sub topic when emails are sent to a gmail account:
const res = await gmail.users.watch({
userId: 'me',
requestBody: {
// Replace with `projects/${PROJECT_ID}/topics/${TOPIC_NAME}`
topicName: `projects/el-gato/topics/gmail`
}
});
console.log(res.data);
所以我写道:
return google.people('v1').people.createContact({
auth: jwtClient,
parent: 'people/me',
requestBody: {
locales: [{ value: 'en' }],
genders: [{ value: 'female' }],
names: [{ givenName: 'Jenny', familyName: 'Doe' }],
emailAddresses: [{ value: 'jenny.doe@example.com' }]
}
})
请求执行时没有任何错误...我可以在mt Google帐户应用联系人中查看新联系人..