1

The post is working properly at postman. But when postman genereate a python code. I've got the following error:

SSLError: HTTPSConnectionPool(host='169.128.117.200', port=50000): Max retries exceeded with url: /b1s/v1/login (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:1056)')))

I just can't understand why postman is working and, the python code is not...

What should I fix at the code to get it working?

import requests
import json

url = "https://169.128.117.200:50000/b1s/v1/login"

payload = json.dumps({
  "Company": "aaaa",
  "Password": "bbbb",
  "UserName": "cccc"
})
headers = {
  'Content-Type': 'application/json',
  'Cookie': 'B1SESSION=230f61c2-d037-11eb-8000-fa163eb6380a; Company=aaaa; ROUTEID=.node2'
}

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

print(response)
martineau
  • 119,623
  • 25
  • 170
  • 301
  • Could you try to add `verify=False` as a parameter to `request.post()`. It will ignore verifying the SSL certificate. See [official documentation](https://2.python-requests.org/en/master/user/advanced/#ssl-cert-verification) – Flo Jun 18 '21 at 15:02
  • Agree to Flo .. Also check at https://www.sslshopper.com/ssl-checker.html whether the ssl certificate on your server was installed correctly if not try reinstalling it – Rudr Thakur Jun 18 '21 at 15:04

1 Answers1

1

The server site provides the https:// url so python request will check its certificate chain. And the error message says that the server site's certificate is self signed. You can use verify=False to ignore the certificate verification.

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