cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1617
Views
0
Helpful
1
Replies

Problems with python script from devzone

stevemadel
Level 1
Level 1

Trying to use the attached code and am getting the following KeyError.  Any ideas?

python3 get-network-hosts.py
/usr/lib/python3.6/site-packages/requests/packages/urllib3/connectionpool.py:852: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
InsecureRequestWarning)
{'totalCount': '1', 'imdata': [{'error': {'attributes': {'code': '6', 'text': 'Output format was not specified (possible options: .xml|.json)'}}}]}
Traceback (most recent call last):
File "get-network-hosts.py", line 50, in <module>
ticket = r_json["response"]["serviceTicket"]
KeyError: 'response'

1 Reply 1

gmonroy
Cisco Employee
Cisco Employee

Stevemadel,

A few things come to mind:

1. In general, KeyErrors imply that you are trying to search on a key that likely doesn't exist. In this case, it is looking for an entry named 'response' within a json dump and is likely not finding it.

2. It looks like that script may have come from this python lab within Cisco DevNet. Assuming you have followed the previous steps correctly, it may be better for you to ask your question on the DevNet Forums as it may have more experts who have run through this lab who can better identify your issue as it specifically pertains to the Lab.

3. The lab and script details look to pertain to the APIC-EM as opposed to the APIC for ACI. The support forum page for the APIC-EM platform can be found here:

Network Management (Including APIC-EM) Support Forums

-Gabriel

Review Cisco Networking for a $25 gift card

Save 25% on Day-2 Operations Add-On License