龙卷风异步后错误500,但卷曲OK
问题描述:
网址是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
我要求是这样的:
答
你发送'content-type': 'application/json',
但数据与body=urllib.urlencode(data).encode('utf-8')
编码。使用json.dumps
而不是urllib.urlencode
。
你怎么调用这个'request'函数?您在python代码中有'method =“GET”',但在curl命令行中有'-X POST'。 –
我这样称呼它的功能(方法等于 “POST”): '体=屈服r.request( URL, 方法=文档[ “方法”], 头=文档[ “标题”], 数据= doc [“data”] )' – lizx