我使用requests
和requests_oauthlib
与API接口。在
我成功地验证并访问了API的所有GET
方法,但是使用POST
方法得到错误500。例如:
r = oauth.post("https://api.timelyapp.com/1.0/1/clients",
data={"client":{"name":"newclient", "color":"c697c0" }},
allow_redirects=False, headers={"Content-Type": "application/json"})
问题是,我用curl
测试了相同的调用,并且它正常工作,这里的curl
代码:
我如何在requests
中更深入地挖掘,以将其调用与curl
进行比较?在
更新:
另外,请注意,如果不指定内容类型:
r = oauth.post("https://api.timelyapp.com/1.0/1/clients",
data={"client":{"name":"newclient", "color":"c697c0" }},
allow_redirects=True)
取而代之的是302,它重定向到站点主页,在那里我获取页面的内容。在任何情况下,都不会添加新客户端。在
您可能需要尝试以下操作:
来自
python-requests
doc:相关问题 更多 >
编程相关推荐