2016-07-24 51 views
0

网址是http://*.*.*.*/100/?id=1&version=1龙卷风异步后错误500,但卷曲OK

params为

{"cityId": "110000", "query": {"queryStr": "line1", "queryExp": ""}, "channelId": "house"} 

curl命令是:

curl -X POST -H "Content-Type: application/json" -d '{"cityId": "110000", "query": {"queryStr": "line1", "queryExp": ""}, "channelId": "house"}' "http://*.*.*.*/100/?id=1&version=1" 

但是当我使用龙卷风(4.2)AsyncHTTPClient,我得到了错误:

tornado.application:Future exception was never retrieved: Traceback (most recent call last): 
... 
HTTPError: HTTP 500: Internal Server Error 

我要求是这样的:

​​
+0

你怎么调用这个'request'函数?您在python代码中有'method =“GET”',但在curl命令行中有'-X POST'。 –

+0

我这样称呼它的功能(方法等于 “POST”): '体=屈服r.request( URL, 方法=文档[ “方法”], 头=文档[ “标题”], 数据= doc [“data”] )' – lizx

回答

0

你发送'content-type': 'application/json',但数据与body=urllib.urlencode(data).encode('utf-8')编码。使用json.dumps而不是urllib.urlencode

+0

thx,我试过了你的建议,没有500状态错误,但是我得到了这个: 'raise ValueError(“No JSON object could be decoding”) 函数 – lizx

+0

尝试'json.dumps(data).encode('utf-8')' – kwarunek

+0

这是一个不同的问题,应该可能是一个单独的问题。打印'http_response.code','http_response.headers'和'http_response.body'来查看你从服务器获得的内容。它真的给你json吗? (你没有发布你的curl命令的输出) –