我试图使用节点的谷歌经销商api插入新客户。我收到400错误

时间:2016-09-02 04:53:06

标签: node.js google-reseller-api

// parmeter

chai

} //使用api

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  "

我收到此错误:

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

2 个答案:

答案 0 :(得分:0)

您可以使用request模块轻松执行此操作。

这是一个插入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"
}

了解更多reference

答案 1 :(得分:0)

问题已在错误日志中说明。

  

原因:消息:'无效值'

"auth":auth未包含在Customers resource

这些是有效值:

{
  "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
}