リクエストを認証し、サンドボックスで顧客を作成しようとしていますが、常にエラー 500 が表示されます。
これは要求です:
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': 'Thu, 21 Feb 2013 11:09:51 GMT', 'server': 'GSE', '-content-encoding': 'gzip', 'cache-control': 'private, max-age= 0', 'date': 'Thu, 21 Feb 2013 11:09:51 GMT', 'x-frame-options': 'SAMEORIGIN', 'content-type': 'application/json; charset=UTF-8' }, '{\n "エラー": {\n "コード": 500,\n "メッセージ": null\n }\n}\n')
これを行う他の方法はありますか?
編集:
私も発見を試しました:
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()
そしてエラーもあります。