简体   繁体   中英

difference between curl and python requests

I am trying to access my firewall API.

and i got a good answer in curl with:

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:

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.

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. In your case, "'Content-type': 'application/json'"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM