I pulled this code from here:
Dell API: Warranty Information · GitHub[
^]
I made some changes:
Comment on Dell API: Warranty Information · GitHub
So the changed code:
1
2
3
4
5
6 import sys
7 import requests
8
9 APIKEY = 'd676cf6e1e0ceb8fd14e8cb69acd812d'
10 URL = 'https://api.dell.com/support/v2/assetinfo/warranty/tags.json?svctags={0}&apikey=' + APIKEY
11
12 def get_warr_from_dell(svctag):
13 res = requests.get(URL.format(svctag))
14
15 if res.status_code != 200:
16 sys.stderr.write('[%s] Caught %i as the response code.\n' % (svctag, res.status_code))
17 sys.stderr.write('[%s] Unable to get details for given service tag.\n'
18 % svctag)
19 return False
20
21 fault = res.json['GetAssetWarrantyResponse']['GetAssetWarrantyResult']['Faults']
22 if fault is not None:
23 sys.stderr.write("[%s] Failed to find details. Sure it's a valid TAG?\n" % svctag )
24 return False
25
26 asset = res.json['GetAssetWarrantyResponse']['GetAssetWarrantyResult']['Response']['DellAsset']
27 model = asset['MachineDescription']
28 ent = asset['Warranties']['Warranty']
29 shipped = asset['ShipDate']
30
31 print ('Service Tag: ', svctag)
32 print (' Model: ', model)
33 print (' Shipped: ', shipped, '\n')
34 print ('{0:<20} {1:>15}'.format(*('Warranty Ends','ServiceLevelDescription')))
35 for warr in [(d['EndDate'],d['ServiceLevelDescription']) for d in ent]:
36 print ('{0:<20} {1:>15}'.format(*warr))
37
38
39 if __name__ == '__main__':
40 get_warr_from_dell(sys.argv[0])
41 sys.exit()
The errors and updates that come after running the above:
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 0x7fa83d980850>: 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='api.dell.com', port=443): Max retries exceeded with url: /support/v2/assetinfo/detail/tags.json?svctags=main.py&apikey=d676cf6e1e0ceb8fd14e8cb69acd812d (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fa83d980850>: 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 36, in <module>
get_parts(sys.argv[0])
File "main.py", line 13, in get_parts
res = requests.get(URL.format(svctag))
File "/usr/lib/python3.8/site-packages/requests/api.py", line 76, in get
return request('get', url, params=params, **kwargs)
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='api.dell.com', port=443): Max retries exceeded with url: /support/v2/assetinfo/detail/tags.json?svctags=main.py&apikey=d676cf6e1e0ceb8fd14e8cb69acd812d (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fa83d980850>: Failed to establish a new connection: [Errno -3] Try again'))
** Process exited - Return Code: 1 **
Press Enter to exit terminal
What I have tried:
I have tried searching parts of errors but landed on nothing. Help is highly appreciated.
Also I tried making myself an API link(dunno if I made it correctly) by putting the api key and a working service tag to the URL and got something - and I can't find the browser history for it. But it looked exacltly like this, which is what you get on the api.dell.com:
Quote:
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:body>
<soapenv:fault>
<faultcode>soapenv:Server
<faultstring>Policy Falsified
<faultactor>https://api.dell.com/
<detail>
<l7:policyresult xmlns:l7="http://www.layer7tech.com/ws/policy/fault" status="Service Not Found. The request may have been sent to an invalid URL, or intended for an unsupported operation.">