Question: get job status using python requests
0
gravatar for robox
12 days ago by
robox0
Belarus
robox0 wrote:

hi ! I'm trying to get job info using curl request like this

curl --insecure --header "Authorization: Token V5KGCRJMSMDMB74OMOOSUXXXXXX5OPUTGHQONFERGYGNL23RXLQ" https://XXX.XXX.XXX.XXX:8443/api/v2/jobs

and everything works fine - i get a response

but when i try to do the same using python requests like this

#/usr/bin/python3
import json
import requests

url = 'https://XXX.XXX.XXX.XXX:8443/api/v2/jobs'
headers = {"Authorization":"Token V5KGCRJMSMDMB74OMOOSUXXXXXX5OPUTGHQONXFERGYGNL23RXLQ"}
r = requests.get(url, headers=headers)
print (r)

i got error

Traceback (most recent call last):
  File "/home/ec2-user/.local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 706, in urlopen
    chunked=chunked,
  File "/home/ec2-user/.local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 382, in _make_request
    self._validate_conn(conn)
  File "/home/ec2-user/.local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 1010, in _validate_conn
    conn.connect()
  File "/home/ec2-user/.local/lib/python3.7/site-packages/urllib3/connection.py", line 421, in connect
    tls_in_tls=tls_in_tls,
  File "/home/ec2-user/.local/lib/python3.7/site-packages/urllib3/util/ssl_.py", line 453, in ssl_wrap_socket
    ssl_sock = _ssl_wrap_socket_impl(sock, context, tls_in_tls)
  File "/home/ec2-user/.local/lib/python3.7/site-packages/urllib3/util/ssl_.py", line 495, in _ssl_wrap_socket_impl
    return ssl_context.wrap_socket(sock)
  File "/usr/lib64/python3.7/ssl.py", line 423, in wrap_socket
    session=session
  File "/usr/lib64/python3.7/ssl.py", line 870, in _create
    self.do_handshake()
  File "/usr/lib64/python3.7/ssl.py", line 1139, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:1091)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ec2-user/.local/lib/python3.7/site-packages/requests/adapters.py", line 449, in send
    timeout=timeout
  File "/home/ec2-user/.local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 756, in urlopen
    method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
  File "/home/ec2-user/.local/lib/python3.7/site-packages/urllib3/util/retry.py", line 574, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='XXX.XXX.XXX.XXX', port=8443): Max retries exceeded with url: /api/v2/jobs (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:1091)')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "resilio.py", line 7, in <module>
    r = requests.get(url, headers=headers)
  File "/home/ec2-user/.local/lib/python3.7/site-packages/requests/api.py", line 75, in get
    return request('get', url, params=params, **kwargs)
  File "/home/ec2-user/.local/lib/python3.7/site-packages/requests/api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "/home/ec2-user/.local/lib/python3.7/site-packages/requests/sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/ec2-user/.local/lib/python3.7/site-packages/requests/sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "/home/ec2-user/.local/lib/python3.7/site-packages/requests/adapters.py", line 514, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='XXX.XXX.XXX.XXX', port=8443): Max retries exceeded with url: /api/v2/jobs (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:1091)')))
ADD COMMENTlink modified 10 days ago • written 12 days ago by robox0
Please log in to add an answer.

Content

Properties

Miscellaneous

Powered by Biostar 16.09
Bug report artem@resilio.com
Traffic: 1 users visited in the last hour