2017-09-05 72 views
0

我需要传递一个字典我的GET请求,但是当这样执行,我得到一个编译错误:如何传递requests.api.request中的参数字典?

patVect = {"poo": 0, "pin": 0, "pok": 0, "pat": 0} 
# querystring = {"patients": "{\"poo\":0, \"pin\":0, \"pok\":0, \"pat\":0}"} 
querystring = {"patients": patVect} 
headers = { 
    'content-type': "application/json", 
    'cache-control': "no-cache", 
} 
response = requests.api.request('get', HURL, headers=headers, params=querystring, verify=False) 

,当我与正常工作的注释查询工作。任何想法为什么这不起作用,或功能,将有所帮助。

+1

这是奇怪的,你可以在调用API之前调试打印查询字符串.request并显示它的价值? – Vinny

+1

你有什么错误? – Grigoriy

+0

你是对的,谢谢你的刺痛,问题出在服务器上,我的错误是连接仍然打开。 requests.exceptions.ConnectionError:('Connection aborted。',RemoteDisconnected('Remote end closed connection without response',)) –

回答

0

的问题是: 查询字符串= { “病人”:json.dumps(patVect)}