2013-02-21 5 views
0

나는 인증 된 내 요청을 수신 샌드 박스에서 고객을 생성하고 난 샌드 박스에서 고객을 만들려고 해요하지만 난 항상이가있는 오류 (500)내가 항상 500 구글 리셀러 API

를받을 요청이 오류 인

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": "[email protected]" 
    } 
    paytext = json.dumps(payload) 
    da = self.client.request(method = 'POST', uri = "https://www.googleapis.com/apps/reseller/v1sandbox/customers/", body =paytext) 

:

('상태'{ '500', '내용 길이' '52', '- XSS 보호 X' '1, 모드 = '차단', 'x-content-type-options': 'nosniff', 'expires': '목, 21 2 월 2013 11:09:51 GMT', '서버': 'GSE' : 'gzip', 'cache-control': '개인, 최대 연령 = 0', '날짜': '목요일, 21 2 월 2013 11:09:51 GMT', 'x-frame-options': 'SAMEORIGIN', 'content-type': 'application/json ; \ n "message": 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() 

그리고 너무 오류가 있습니다.

답변

0

을 표시합니다. 우리는 함께 샌드 박스 고객을 만들 수있었습니다. 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

이것은 고객을 만드는 데 필요한 최소한의 정보 인 것 같습니다.

승인을 이미 처리했다고 가정합니다. 한 가지주의해야 할 점은 서비스 계정을 사용하는 경우 고객을 만들 수있는 액세스 권한을 가진 사용자로 가장해야합니다.