0

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

6
  • Does the API docs says what kind of content-type it accepts? Commented Mar 26, 2019 at 14:26
  • 3
    Why are you sending an application/json content type? Commented Mar 26, 2019 at 14:28
  • With @moritzg. Especially since you aren't POSTing any data. Commented Mar 26, 2019 at 14:32
  • Henkq: uses two different content types for requests. Server: performs differently. Henkq: Pikachu face. Commented Mar 26, 2019 at 14:33
  • @Stargazer : API docs said mime-type accept application/json and text/plain Commented Mar 26, 2019 at 21:30

1 Answer 1

2

As far as I know, and according to the RFC 2045, the content type should be lowercase. In your case, "'Content-type': 'application/json'"

Sign up to request clarification or add additional context in comments.

2 Comments

This is correct and valuable, but doesn't actually answer the question. It should be a comment on the question. Especially since it's not clear why the OP is using that content type in the first place.
@sne4ky, put content-type in lower case doesnt slove the pb. and whitout content-type headers. Il's the same.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.