[英]difference between curl and python requests
I am trying to access my firewall API. 我正在尝试访问防火墙API。
and i got a good answer in curl with: 我在curl中得到了一个很好的答案:
curl -k -i -u admin:xxxx -X POST https://10.0.0.2:9443/api/sonicos/auth
#=> Ok
with requests, api said HTTP 406 here is my code: 对于请求,api表示HTTP 406是我的代码:
import requests
from requests.auth import HTTPBasicAuth
r = requests.post(
'https://10.0.0.2:9443/api/sonicos/auth',
auth=HTTPBasicAuth('admin', 'xxxx'),
headers={'Content-type': 'Application/JSON'},
verify=False
)
API documentation said: 406 Not acceptable Mime-type in content-type not supported. API文档说:406不支持在内容类型中不支持Mime类型。
I try a lot of parameters without success. 我尝试很多参数都没有成功。 Any idea to help me?
有什么办法可以帮助我吗?
Thanx 谢谢
As far as I know, and according to the RFC 2045, the content type should be lowercase. 据我所知,根据RFC 2045,内容类型应为小写。 In your case, "'Content-type': 'application/json'"
在您的情况下,“'Content-type':'application / json'“
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.