2013-10-24 3 views
0

bigquery 테이블에 스트리밍 삽입을 시도하고 http 500 오류가 발생했습니다. "예기치 않은 오류가 발생했습니다. 다시 시도하십시오." 내가 도대체 ​​뭘 잘못하고있는 겁니까?스트리밍 삽입 Python에서 HTTP 500 오류

credentials =AppAssertionCredentials(scope='https://www.googleapis.com/auth/bigquery') 
http = credentials.authorize(httplib2.Http(memcache)) 
service = build('bigquery', 'v2', http=http) 
self.tabledata = service.tabledata() 
body = '{"rows": [{"json": {"userid": 1, "client": 1, "type": 1, "time": 0.0}}]}' 
response = self.tabledata.insertAll(projectId=PROJECT_ID, datasetId='hunter', tableId='test', body=body).execute() 

내가 얻을 스택 추적 :

2013-10-24 09:49:58.167 Encountered unexpected error from ProtoRPC method implementation: HttpError (<HttpError 500 when requesting https://www.googleapis.com/bigquery/v2/projects/avalanche-test/datasets/hunter/tables/test/insertAll?alt=json returned "Unexpected. Please try again.">) 
Traceback (most recent call last): 
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/protorpc-1.0/protorpc/wsgi/service.py", line 181, in protorpc_service_app 
response = method(instance, request) 
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/endpoints-1.0/endpoints/api_config.py", line 1321, in invoke_remote 
return remote_method(service_instance, request) 
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/protorpc-1.0/protorpc/remote.py", line 412, in invoke_remote_method 
response = method(service_instance, request) 
File "/base/data/home/apps/s~avalanche-test/1.371139085360971734/main.py", line 27, in trackLogin 
self.track(evt) 
File "/base/data/home/apps/s~avalanche-test/1.371139085360971734/main.py", line 22, in track 
resp = logging.info(self.helper.insertEvent(evt)) 
File "/base/data/home/apps/s~avalanche-test/1.371139085360971734/bigquery.py", line 27, in insertEvent 
response = self.tabledata.insertAll(projectId=PROJECT_ID, datasetId='hunter', tableId='test', body=body).execute() 
File "/base/data/home/apps/s~avalanche-test/1.371139085360971734/oauth2client/util.py", line 132, in positional_wrapper 
return wrapped(*args, **kwargs) 
File "/base/data/home/apps/s~avalanche-test/1.371139085360971734/apiclient/http.py", line 723, in execute 
raise HttpError(resp, content, uri=self.uri) 
HttpError: <HttpError 500 when requesting https://www.googleapis.com/bigquery/v2/projects/avalanche-test/datasets/hunter/tables/test/insertAll?alt=json returned "Unexpected. Please try again."> 

답변

2

나는 문제가 당신이 몸으로 JSON 인코딩 된 문자열을 전달하는 것을 믿습니다.

본문은 JSON 구조와 동등한 파이썬이어야합니다. 전화는 다음과 같이 표시되어야합니다.

response = self.tabledata.insertAll(projectId=PROJECT_ID, datasetId='hunter', tableId='test', body={rows: [{json: {userid: 1, client: 1, type: 1, time: 0.0}}, ...]}).execute() 
+0

예. 정확히 문제였습니다. 잘 작동합니다! – Jumfer