首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >流插入Python上的HTTP 500错误

流插入Python上的HTTP 500错误
EN

Stack Overflow用户
提问于 2013-10-24 07:58:45
回答 1查看 244关注 0票数 0

我尝试在bigquery表中执行流插入,并得到http 500错误“意外。请再试一次”。我做错了什么?

代码语言:javascript
复制
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()

我得到的堆栈跟踪是:

代码语言:javascript
复制
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."> 
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-10-24 18:24:32

我认为问题在于,您将JSON编码的字符串作为主体传递。

主体应该是相当于JSON结构的python。所以这个电话看起来应该是:

代码语言:javascript
复制
response = self.tabledata.insertAll(projectId=PROJECT_ID, datasetId='hunter', tableId='test', body={rows: [{json: {userid: 1, client: 1, type: 1, time: 0.0}}, ...]}).execute()
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19560189

复制
相关文章

相似问题

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