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

APIC-EM

Blake Hoelzel
Level 1
Level 1

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

1 Accepted Solution

Accepted Solutions

amwhaley
Cisco Employee
Cisco Employee

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!

View solution in original post

2 Replies 2

amwhaley
Cisco Employee
Cisco Employee

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!

That did the trick -- thank you!