首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在沙箱中创建客户时,我总是收到一个500。Google Reseller API

在沙箱中创建客户时,我总是收到一个500。Google Reseller API
EN

Stack Overflow用户
提问于 2013-02-21 19:17:05
回答 2查看 370关注 0票数 0

我已经验证了我的请求,并且我正在尝试在沙箱中创建一个客户,但我总是收到一个错误500。

这是请求:

代码语言:javascript
复制
  self.cred =  OAuth2Credentials(access_token = access_token, client_id = client_id,
                            client_secret = client_secret, refresh_token = refresh_token,
                            token_expiry = None, token_uri ="https://accounts.google.com/o/oauth2/token",
                            user_agent = None, id_token = None)

  self.client = httplib2.Http()
  self.cred.refresh(self.client)
  self.client = self.cred.authorize(self.client)
  payload = {
      "kind": "reseller#customer",
      "customerId": "example.com",
      "customerDomain": "example.com",
      "postalAddress": {
        "kind": "customers#address",
        "contactName": "John Doe",
        "organizationName": "Example Inc",
        "locality": "Mountain View",
        "region": "California",
        "postalCode": "94043",
        "countryCode": "US",
        "addressLine1": "1600 Amphitheatre Parkway",
        "addressLine2": "Mountain View",
        "addressLine3": "California"
      },
      "phoneNumber": "+1 650-253-0000",
      "alternateEmail": "alternateEmail@google.com"
    }
  paytext = json.dumps(payload)
  da = self.client.request(method = 'POST', uri = "https://www.googleapis.com/apps/reseller/v1sandbox/customers/", body =paytext)

这是错误:

({'status':'500','content-length':'52','x-xss-protection':'1;mode=block','x-content-type-options':'nosniff','expires':‘清华,2013年2月21日11:09:51 GMT','server':'GSE','-content-encoding':'gzip','cache-control':'private,max-age=0','date':’清华,2013年2月21日11:09:51 GMT','x-frame-options':'SAMEORIGIN','content-type':'application/json;字符集=UTF-8‘},'{\n“错误”:{\n“代码”:500,\n“消息”:null\n }\n}\n')

有没有其他方法可以做到这一点?

编辑:

我也尝试过这个发现:

代码语言:javascript
复制
from apiclient.discovery import build
import httplib2
http = httplib2.Http()
from oauth2client.client import OAuth2Credentials
cred =  OAuth2Credentials(access_token = access_token, client_id = client_id,
                                client_secret = client_secret, refresh_token = refresh_token,
                                token_expiry = None, token_uri ="https://accounts.google.com/o/oauth2/token" ,
                                user_agent = None, id_token = None)
client = httplib2.Http()
cred.refresh(client)
client = cred.authorize(client)
api = build(serviceName='reseller',version='v1sandbox',http=client)
api.customers().insert(body=payload).execute()

而且也有一个错误。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-02-25 06:52:37

我相信您的问题与问题跟踪器中最近的bug有关。

http://code.google.com/a/google.com/p/apps-api-issues/issues/detail?id=3346

票数 0
EN

Stack Overflow用户

发布于 2015-07-10 04:53:31

我认为他们已经修复了他们的bug,尽管它似乎没有标记为已修复。我们能够使用创建一个沙箱客户。下面是Ruby语言的要点:def self.create response = client.execute( :api_method => service.customers.insert, :body_object => { :customerDomain => domain, :alternateEmail => alternate_email, :postalAddress => { :contactName => contact_name, :organizationName => organization_name, :countryCode => two_letter_country_code, :region => region, :addressLine1 => street_address, :locality => city, :postalCode => zip } }, :authorization => authorization ) GoogleCustomer.new(response.data) end

这似乎是创建客户所需的最低限度的信息。

这里假设您已经处理了授权。需要注意的一件事是:如果您使用的是服务帐户,则需要模拟具有创建客户权限的用户。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15000876

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档