The CreatorCon Call for Content is officially open! Get started here.

REST API Integration: certificate verify failed (_ssl.c:877)

Fitri
Giga Contributor

Hi, I tried do some integration towards serviceNow using python script and referring example given in this link to update the records: Table API Python

Here is my code:

#Need to install requests package for python
#sudo easy_install requests
import requests
 
# Set the request parameters
url = 'https://company.owndomain.com/api/now/table/sc_req_item/2a2851fe88709010b9120e9b506dd9a9'
user = 'username'
pwd = 'password'
 
# Set proper headers
headers = {"Content-Type":"application/json","Accept":"application/json"}
 
# Do the HTTP request
response = requests.patch(url, auth=(user, pwd), headers=headers ,data='{"u_switch_status_automation":"In Processing using Python", "u_switch_description":"The Automation currently processing this SR using Python"}')
 
# Check for HTTP codes other than 200
if response.status_code != 200: 
  print('Status:', response.status_code, 'Headers:', response.headers, 'Error Response:',response.json())
  exit()
 
 # Decode the JSON response into a dictionary and use the data
print('Status:',response.status_code,'Headers:',response.headers,'Response:',response.json())

 

And the result I got is as follows:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 343, in _make_request
    self._validate_conn(conn)
  File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 839, in _validate_conn
    conn.connect()
  File "/usr/lib/python3.6/site-packages/urllib3/connection.py", line 344, in connect
    ssl_context=context)
  File "/usr/lib/python3.6/site-packages/urllib3/util/ssl_.py", line 347, in ssl_wrap_socket
    return context.wrap_socket(sock, server_hostname=server_hostname)
  File "/usr/lib64/python3.6/ssl.py", line 365, in wrap_socket
    _context=self, _session=session)
  File "/usr/lib64/python3.6/ssl.py", line 773, in __init__
    self.do_handshake()
  File "/usr/lib64/python3.6/ssl.py", line 1033, in do_handshake
    self._sslobj.do_handshake()
  File "/usr/lib64/python3.6/ssl.py", line 645, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:877)

Am I missing something or need to do some configuration for this? 

1 ACCEPTED SOLUTION

Hi,

I tried it and for me it work from one of my MID server using python.

Thanks,
Ashutosh

View solution in original post

11 REPLIES 11

Hi,

I tried it and for me it work from one of my MID server using python.

Thanks,
Ashutosh

Hi,

So there is nothing wrong with the script. I guess need check configuration either from SNOW side or from server side then. 

Thanks, 
Fitri Izuan