如何使用Google contacts api v3创建新联系人-使用javascript
即使这个问题在过去的一年里被多次提出,它仍然没有得到正确的解决。。。尤其是在使用最新的googleapis库时!GoogleDoc没有什么用处,因为仍然提到了许多不推荐的方法,并且没有给出javascript示例 使用people.get()(在list()之后)我可以看到它应该是什么样子(我猜) 所以我试着用这种方式创造一个新的人:如何使用Google contacts api v3创建新联系人-使用javascript,javascript,google-api,google-people,Javascript,Google Api,Google People,即使这个问题在过去的一年里被多次提出,它仍然没有得到正确的解决。。。尤其是在使用最新的googleapis库时!GoogleDoc没有什么用处,因为仍然提到了许多不推荐的方法,并且没有给出javascript示例 使用people.get()(在list()之后)我可以看到它应该是什么样子(我猜) 所以我试着用这种方式创造一个新的人: return google.people('v1').people.createContact({ auth: jwtClient,
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']
})
但是不可能。。。我总是犯错误:
Invalid JSON payload received. Unknown name \"genders\": Cannot bind query parameter. Field 'genders' could not be found in request message.
Invalid JSON payload received. Unknown name \"locales\": Cannot bind query parameter. Field 'locales' could not be found in request message.
Invalid JSON payload received. Unknown name \"names[familyName]\": Cannot bind query parameter. Field 'names[familyName]' could not be found in request message.
Invalid JSON payload received. Unknown name \"emailAddresses\": Cannot bind query parameter. Field 'emailAddresses' could not be found in request message.
Invalid JSON payload received. Unknown name \"names[givenName]\": Cannot bind query parameter. Field 'names[givenName]' could not be found in request message.
Invalid JSON payload received. Unknown name \"resourceName\":Cannot bind query parameter. Field 'resourceName' could not be found in request message.
网络上有什么例子吗
欢迎反馈。。。(即使是来自谷歌的人…哈哈)在仔细检查(可能是三倍…)文档后,我阅读了
于是我写道:
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帐户应用程序联系人中看到新联系人
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' }]
}
})