Anonymous2183
I pulled this code from here: https://gist.github.com/teroka/0720274b87b77fe7171f
I made some changes:
https://gist.github.com/teroka/0720274b87b77fe7171f#gistcomment-3911903
So the changed code:
```python
# Quick script to check your Dell asset's warranty status
# Just drop your service tag as parameters for the script and go.
import sys
import requests
APIKEY = 'd676cf6e1e0ceb8fd14e8cb69acd812d'
URL = 'https://api.dell.com/support/v2/assetinfo/warranty/tags.json?svctags={0}&apikey=' + APIKEY
def get_warr_from_dell(svctag):
res = requests.get(URL.format(svctag))
if res.status_code != 200:
sys.stderr.write('[%s] Caught %i as the response code.\n' % (svctag, res.status_code))
sys.stderr.write('[%s] Unable to get details for given service tag.\n'
% svctag)
return False
fault = res.json['GetAssetWarrantyResponse']['GetAssetWarrantyResult']['Faults']
if fault is not None:
sys.stderr.write("[%s] Failed to find details. Sure it's a valid TAG?\n" % svctag )
return False
asset = res.json['GetAssetWarrantyResponse']['GetAssetWarrantyResult']['Response']['DellAsset']
model = asset['MachineDescription']
ent = asset['Warranties']['Warranty']
shipped = asset['ShipDate']
print ('Service Tag: ', svctag)
print (' Model: ', model)
print (' Shipped: ', shipped, '\n')
print ('{0:<20} {1:>15}'.format(*('Warranty Ends','ServiceLevelDescription')))
for warr in [(d['EndDate'],d['ServiceLevelDescription']) for d in ent]:
print ('{0:<20} {1:>15}'.format(*warr))
if __name__ == '__main__':
get_warr_from_dell(sys.argv[0])
sys.exit()
```
[The errors and updates that come after running the above - scroll to the last code block of the highlighted comment][1].
The error that come after running the above:
```terminal
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
```
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:
```xml
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.">
```
[1]: https://gist.github.com/teroka/0720274b87b77fe7171f#gistcomment-3911903