我正在尝试使用Directory API更新客户对象,但尝试修改顶级的任何内容会导致返回400(无效客户语言)错误。
这是初始对象的获取(一些项目是为隐私而编辑的)
请求
GET https://www.googleapis.com/admin/directory/v1/customers/<customerID>
响应
200 OK
{
"kind": "admin#directory#customer",
"id": "<customerID>",
"etag": "\"<etag>\"",
"customerDomain": "<domainName>",
"alternateEmail": "<email>",
"postalAddress": {
"contactName": "<name>",
"organizationName": "",
"locality": "<city>",
"region": "<state>",
"countryCode": "US",
"addressLine1": "<address1>",
"addressLine2": "",
"addressLine3": "",
"postalCode": "<zip>"
},
"phoneNumber": "<phoneNumber>",
"language": "en",
"customerCreationTime": "2011-03-31T03:45:49.408Z"
}
尝试单独更新电话号码或语言会导致错误。如果我使用补丁或更新呼叫并不重要。
电话号码补丁电话:
{
"phoneNumber": "+18005551234"
}
语言补丁电话:
{
"language": "en-GB"
}
修补或更新通话回复
400 OK
{
"error": {
"errors": [
{
"domain": "global",
"reason": "invalid",
"message": "Invalid Customer language"
}
],
"code": 400,
"message": "Invalid Customer language"
}
}
现在我正在玩在线工具(https://developers.google.com/admin-sdk/directory/v1/reference/customers/patch),然后我将其拉入代码。我没有在文档,论坛,问题跟踪器或此处找到解决问题的任何内容;任何帮助将不胜感激!
答案 0 :(得分:3)
看起来这是在线工具的一个错误。我能够使用更新版本的GAM(https://github.com/jay0lee/GAM)成功操作对象,并准备继续前进。我会留下这个以防万一其他人遇到问题。
答案 1 :(得分:0)
使用PUT请求对我有用,在node-sdk中我有这样的东西:
google.admin('directory_v1').customers.update({
auth: auth,
customerKey: 'my_customer'
resource: {
customerDomain: 'some-domain',
}
}, function(err, response) {
// Some code
}