我正试图使用节点的谷歌经销商api插入新客户.我得到了400个错误



//参数

var params = {
"auth":auth,
"kind": "reseller#customer",
"customerId": "customerId",
"customerDomain": "customer domain",
"postalAddress": {
  "kind": "customers#address",
  "contactName": "John Doe",
  "organizationName": "Example Inc",
  "postalCode": "94043",
  "countryCode": "US",
},
"alternateEmail": "email address  "

}//使用api

var service = google.reseller('v1');
service.customers.insert(params,function(err,data){
   console.log(err);
   console.log(data); 
})

我得到这个错误:

{ [Error: Invalid Value]
  code: 400,
  errors: [ { domain: 'global', reason: 'invalid', message: 'Invalid Value' } ] }

您可以使用请求模块来简单地执行此操作。

下面是一个插入customer的示例,执行它

POST https://www.googleapis.com/apps/reseller/v1/customers

    Body parameter
  {
  "kind": "reseller#customer",
  "customerId": "custId-1234",
  "customerDomain": "example.com",
  "postalAddress": {
    "kind": "customers#address",
    "contactName": "John Doe",
    "organizationName": "Example Inc",
    "postalCode": "94043",
    "countryCode": "US",
  },
  "alternateEmail": "alternateEmail@google.com"
}

查看更多参考

错误日志中已经说明了这个问题。

原因:message: 'Invalid Value'

"auth":auth不包含在Customers资源中。

以下是有效值:

{
  "kind": "reseller#customer",
  "customerId": string,
  "customerDomain": string,
  "postalAddress": {
    "kind": "customers#address",
    "contactName": string,
    "organizationName": string,
    "locality": string,
    "region": string,
    "postalCode": string,
    "countryCode": string,
    "addressLine1": string,
    "addressLine2": string,
    "addressLine3": string
  },
  "phoneNumber": string,
  "alternateEmail": string,
  "resourceUiUrl": string,
  "customerDomainVerified": boolean
}

相关内容

  • 没有找到相关文章