cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
794
Views
0
Helpful
2
Replies

Coding & APIs - Coding 2002 - Parsing JSON

acdlinoxx
Level 1
Level 1

Hi,

When can i run code "get-ap-json.py" this return the message: [Errno 11001] getaddrinfo failed. Why?

This code is:

from urllib.request import Request, urlopen
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
req = Request('https://cmxlocationsandbox.cisco.com/api/config/v1/maps/info/DevNetCampus/DevNetBuilding/DevNetZone')
req.add_header('Authorization', 'Basic bGVhcm5pbmc6bGVhcm5pbmc=')
response = urlopen(req)
response_string = response.read().decode('utf-8')
print(response_string)
response.close()

Thanks.

2 Replies 2

Seb Rupik
VIP Alumni
VIP Alumni

Hi there,

This error is either called by a DNS or a HTTP proxy issue.

 

If you are behind a proxy,. make the following changes to your code:

proxy_dict = {"http": <ip_address_of_proxy>:<proxy_port>, 
              "https: <ip_address_of_proxy>:<proxy_port>}

req = Request('https://cmxlocationsandbox.cisco.com/api/config/v1/maps/info/DevNetCampus/DevNetBuilding/DevNetZone',
proxies=proxy_dict)

cheers,

Seb.

Hey there, can you share where or what resource you are following please?

 

Thanks!

Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io