3

even though i keep verify= false, i'm getting ssl error in python. Could you tell me how do I avoid it? But curl command is working with -k option.

import json
import requests

url = "https://<url>/context"
payload = {"some":"data"}
headers = {"Authorization": "Basic:xxxxxxxxxx"}

response = requests.post(url, verify=False, 
data=json.dumps(payload), headers=headers)

print(response)

error:

/usr/lib/python2.7/site-packages/urllib3/connectionpool.py:769: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html InsecureRequestWarning)

3
  • 1
    That's no error, that's a warning. Also, the warning message even gave you directly the link discussing how to handle it. Commented Apr 4, 2017 at 6:37
  • Furthermore, Authorization header doesn't work like that. You need a space after Basic. Commented Apr 4, 2017 at 6:42
  • ah! my bad. thank you for pointing the error. :) Commented Apr 4, 2017 at 9:52

1 Answer 1

1

It is just a warning. You can disable these warnings.

from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.