cancel
Showing results for 
Search instead for 
Did you mean: 

Error with API Call in Python

JPitson
Novitiate I

Hi Everyone 

I'm having an issue with using a Jumpcloud call API in Python.  I'm trying to extract from our Jumpcloud devices list, the serial number and OS version.  After this I will do an API Call to Jira assets to update The OS Version where the serial number matches.

I think it's falling down here:

import requestsjumpcloud_api_key = 'averylongapikey'
jumpcloud_url = 'https://console.jumpcloud.com/api/systems'

headers = {'x-api-key': jumpcloud_api_key}
response = requests.get(jumpcloud_url, headers=headers)
laptops = json.loads(response.text)

However, this outputs the following error:

Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/urllib3/connection.py", line 159, in _new_conn
conn = connection.create_connection(
File "/usr/lib/python3.8/site-packages/urllib3/util/connection.py", line 61, in create_connection
for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
File "/usr/lib/python3.8/socket.py", line 918, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Try again
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/urllib3/connectionpool.py", line 670, in urlopen
httplib_response = self._make_request(
File "/usr/lib/python3.8/site-packages/urllib3/connectionpool.py", line 381, in _make_request
self._validate_conn(conn)
File "/usr/lib/python3.8/site-packages/urllib3/connectionpool.py", line 976, in _validate_conn
conn.connect()
File "/usr/lib/python3.8/site-packages/urllib3/connection.py", line 308, in connect
conn = self._new_conn()
File "/usr/lib/python3.8/site-packages/urllib3/connection.py", line 171, in _new_conn
raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7fa650b4f340>: Failed to establish a new connection: [Errno -3] Try again
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/requests/adapters.py", line 439, in send
resp = conn.urlopen(
File "/usr/lib/python3.8/site-packages/urllib3/connectionpool.py", line 724, in urlopen
retries = retries.increment(
File "/usr/lib/python3.8/site-packages/urllib3/util/retry.py", line 439, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='console.jumpcloud.com', port=443): Max retries exceeded with url: /api/systems (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fa650b4f340>: Failed to establish a new connection: [Errno -3] Try again'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "main.py", line 17, in <module>
response = requests.request("GET", jumpcloud_url, headers=headers)
File "/usr/lib/python3.8/site-packages/requests/api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/lib/python3.8/site-packages/requests/sessions.py", line 530, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python3.8/site-packages/requests/sessions.py", line 643, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python3.8/site-packages/requests/adapters.py", line 516, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='console.jumpcloud.com', port=443): Max retries exceeded with url: /api/systems (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fa650b4f340>: Failed to establish a new connection: [Errno -3] Try again'))


** Process exited - Return Code: 1 **

I've checked the API references and I believe I am doing using the correct URL.  I've tried renewing my API key to see if that was the case.  Can anyone help?

 

 

3 REPLIES 3

urvashi
Bronze I
Bronze I

Hi @JPitson I think it would be best if you reached out to support for this. They can work with you on a call to debug and get it fixed 🙂

https://jumpcloud.com/support/contact-jumpcloud-support

abalolop
Novitiate I

Hello.

Any ideas how to solve it? I have the same problem. So let me know

@abalolop it's recommended that you get in touch with our support team to get help with this. 

You Might Like

New to the site? Take a look at these additional resources:

Community created scripts

Keep up with Product News

Read our community guidelines

Ready to join us? You can register here.