03-30-2015 10:43 PM - edited 06-04-2019 02:17 AM
I'm trying to run the simple script below and getting the errors. What am I missing?
Thanks
import requests
controller = "http://10.10.10.111/"
get_devices_url = controller + 'api/v0/network-device'
get_devices_response = requests.get(get_devices_url)
print "Devices = "
print get_devices_response.text
Script on port 80...
Traceback (most recent call last):
File "apic-em-helloworld.py", line 37, in <module>
get_devices_response = requests.get(get_devices_url)
File "/Library/Python/2.7/site-packages/requests-2.6.0-py2.7.egg/requests/api.py", line 68, in get
return request('get', url, **kwargs)
File "/Library/Python/2.7/site-packages/requests-2.6.0-py2.7.egg/requests/api.py", line 50, in request
response = session.request(method=method, url=url, **kwargs)
File "/Library/Python/2.7/site-packages/requests-2.6.0-py2.7.egg/requests/sessions.py", line 464, in request
resp = self.send(prep, **send_kwargs)
File "/Library/Python/2.7/site-packages/requests-2.6.0-py2.7.egg/requests/sessions.py", line 576, in send
r = adapter.send(request, **kwargs)
File "/Library/Python/2.7/site-packages/requests-2.6.0-py2.7.egg/requests/adapters.py", line 415, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', BadStatusLine("''",))
Script trying 443...
/Library/Python/2.7/site-packages/requests-2.6.0-py2.7.egg/requests/packages/urllib3/util/ssl_.py:79: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Traceback (most recent call last):
File "apic-em-helloworld.py", line 37, in <module>
get_devices_response = requests.get(get_devices_url)
File "/Library/Python/2.7/site-packages/requests-2.6.0-py2.7.egg/requests/api.py", line 68, in get
return request('get', url, **kwargs)
File "/Library/Python/2.7/site-packages/requests-2.6.0-py2.7.egg/requests/api.py", line 50, in request
response = session.request(method=method, url=url, **kwargs)
File "/Library/Python/2.7/site-packages/requests-2.6.0-py2.7.egg/requests/sessions.py", line 464, in request
resp = self.send(prep, **send_kwargs)
File "/Library/Python/2.7/site-packages/requests-2.6.0-py2.7.egg/requests/sessions.py", line 602, in send
history = [resp for resp in gen] if allow_redirects else []
File "/Library/Python/2.7/site-packages/requests-2.6.0-py2.7.egg/requests/sessions.py", line 195, in resolve_redirects
allow_redirects=False,
File "/Library/Python/2.7/site-packages/requests-2.6.0-py2.7.egg/requests/sessions.py", line 576, in send
r = adapter.send(request, **kwargs)
File "/Library/Python/2.7/site-packages/requests-2.6.0-py2.7.egg/requests/adapters.py", line 431, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: [Errno 1] _ssl.c:507: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Solved! Go to Solution.
03-31-2015 07:11 AM
Hello -
It looks like you are having a problem with the self signed cert that is used in the Sandbox lab.
Try adding 'verify=False' to the request.get method parameters. This parameter will direct requests to skip the cert validation. This parameter is OK for testing, and experimentation, but shouldn't be used in production, of course.
Here is an example:
get_devices_response = requests.get(get_devices_url, verify=False)
Give that a try, and let me know if that helps!
thanks!
03-31-2015 07:11 AM
Hello -
It looks like you are having a problem with the self signed cert that is used in the Sandbox lab.
Try adding 'verify=False' to the request.get method parameters. This parameter will direct requests to skip the cert validation. This parameter is OK for testing, and experimentation, but shouldn't be used in production, of course.
Here is an example:
get_devices_response = requests.get(get_devices_url, verify=False)
Give that a try, and let me know if that helps!
thanks!
04-06-2015 09:56 PM
That did the trick -- thank you!
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide