Join 34,000+ subscribers and receive articles from our blog about software quality, testing, QA and security.
 

Issues with python API

Hi there,

I am trying to access testrail using the python API. Here’s the code snippet (replaced the actual user name & API token w/ xxxx). I am using the python testrail package 3.0 and my python version is 3.7

from testrail import *
import requests
import ssl
URL = ‘https://trail.xxxx.local/testrail
client = APIClient(URL)
client.user = "skv@xxxx.com"
client.password = “xxxxxxxxxxxxxxxxxxxxxxx”
projects_list = client.send_get(‘get_projects’)
print(f’List of test rail projects {projects_list}’)

I am getting this error. I’ve looked up online & tried suggestions provided but nothing seems to be working. Anyone can help take a look & suggest how to resolve this issue

Traceback (most recent call last):
File “C:\Users\skv\src\sandbox\venv\lib\site-packages\urllib3\connectionpool.py”, line 603, in urlopen
chunked=chunked)
File “C:\Users\skv\src\sandbox\venv\lib\site-packages\urllib3\connectionpool.py”, line 344, in _make_request
self._validate_conn(conn)
File “C:\Users\skv\src\sandbox\venv\lib\site-packages\urllib3\connectionpool.py”, line 843, in validate_conn
conn.connect()
File “C:\Users\skv\src\sandbox\venv\lib\site-packages\urllib3\connection.py”, line 370, in connect
ssl_context=context)
File "C:\Users\skv\src\sandbox\venv\lib\site-packages\urllib3\util\ssl
.py", line 355, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File “C:\Users\skv\AppData\Local\Programs\Python\Python37\lib\ssl.py”, line 412, in wrap_socket
session=session
File “C:\Users\skv\AppData\Local\Programs\Python\Python37\lib\ssl.py”, line 853, in _create
self.do_handshake()
File “C:\Users\skv\AppData\Local\Programs\Python\Python37\lib\ssl.py”, line 1117, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “C:\Users\skv\src\sandbox\venv\lib\site-packages\requests\adapters.py”, line 449, in send
timeout=timeout
File “C:\Users\skv\src\sandbox\venv\lib\site-packages\urllib3\connectionpool.py”, line 641, in urlopen
_stacktrace=sys.exc_info()[2])
File “C:\Users\skv\src\sandbox\venv\lib\site-packages\urllib3\util\retry.py”, line 399, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host=‘trail.xxxxx.local’, port=443): Max retries exceeded with url: /testrail/index.php?/api/v2/get_projects (Caused by SSLError(SSLCertVerificationError(1, ‘[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)’)))

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “C:/Users/skv/src/sandbox/app.py”, line 12, in
projects_list = client.send_get(‘get_projects’)
File “C:\Users\skv\src\sandbox\testrail.py”, line 42, in send_get
return self.__send_request(‘GET’, uri, filepath)
File “C:\Users\skv\src\sandbox\testrail.py”, line 84, in __send_request
response = requests.get(url, headers=headers)
File “C:\Users\skv\src\sandbox\venv\lib\site-packages\requests\api.py”, line 75, in get
return request(‘get’, url, params=params, **kwargs)
File “C:\Users\skv\src\sandbox\venv\lib\site-packages\requests\api.py”, line 60, in request
return session.request(method=method, url=url, **kwargs)
File “C:\Users\skv\src\sandbox\venv\lib\site-packages\requests\sessions.py”, line 533, in request
resp = self.send(prep, **send_kwargs)
File “C:\Users\skv\src\sandbox\venv\lib\site-packages\requests\sessions.py”, line 646, in send
r = adapter.send(request, **kwargs)
File “C:\Users\skv\src\sandbox\venv\lib\site-packages\requests\adapters.py”, line 514, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host=‘trail.xxxx.local’, port=443): Max retries exceeded with url: /testrail/index.php?/api/v2/get_projects (Caused by SSLError(SSLCertVerificationError(1, ‘[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)’)))
Process finished with exit code 1