Meraki Python API error

morris
Comes here often

Meraki Python API error

I tested the code from https://developer.cisco.com/meraki/api/#!get-organization-api-requests but received a SSL certificate error.

 

 

import meraki

# Defining your API key as a variable in source code is not recommended
API_KEY = '[REMOVED]'
# Instead, use an environment variable as shown under the Usage section
# @ https://github.com/meraki/dashboard-api-python/

dashboard = meraki.DashboardAPI(API_KEY)

organization_id = '[REMOVED]'

response = dashboard.api_usage.getOrganizationApiRequests(
    organization_id, total_pages='all'
)

print(response)

 

 

 

Then I search around Internet and found this https://community.meraki.com/t5/Developers-APIs/Dashboard-API-via-Python-unable-to-get-local-issuer-... but how do I get the certificate? And why the file path is using double \\?

12 REPLIES 12
BrechtSchamp
Kind of a big deal

I'm unsure about your error. I just tried it in a pycharm project and it works fine here.

 

The double backslash is because the backslash is used as an escape character in python. So you need to escape it... with a backslash.

 

"The backslash (\) character is used to escape characters that otherwise have a special meaning, such as newline, backslash itself, or the quote character. String literals may optionally be prefixed with a letter `r' or `R'; such strings are called raw strings and use different rules for backslash escape sequences."

 

More info here:

https://docs.python.org/2.0/ref/strings.html

You're able to run the code without specifying the SSL certificate?

BrechtSchamp
Kind of a big deal

Yes, I ran that exact code with my API key and my orgId.

 

I'm using Python 3.7 and Meraki library 0.80.3 in a pycharm project on Windows.

rhbirkelund
Kind of a big deal

You really need to remove that API key, from the example, ASAP!

 

You do not share an API key on the internet, as it can be used malicously!

LinkedIn ::: https://blog.rhbirkelund.dk/

Like what you see? - Give a Kudo ## Did it answer your question? - Mark it as a Solution 🙂

All code examples are provided as is. Responsibility for Code execution lies solely your own.

That's the API key from the sample code, no worries.

Fair enough, then. 🙂
LinkedIn ::: https://blog.rhbirkelund.dk/

Like what you see? - Give a Kudo ## Did it answer your question? - Mark it as a Solution 🙂

All code examples are provided as is. Responsibility for Code execution lies solely your own.

was going to reply that. haha

miguelsalas
New here

Hi morris,

 

I am just programming at the moment and I am working with the api v1.0 beta and there is no api_usage method

What version of the meraki library are you working with?

PhilipDAth
Kind of a big deal
Kind of a big deal

What is the underlying OS?  Has the OS environment got the typical root CA certificates installed?

ok, now I can run the code in the non-proxy environment.

But code display the Networks in terminal, so how do I pipe the output to a file like .TXT or .CSV?

 

Where can I find documentation for the interaction between python and Meraki API? Because I would like to try other things.

 

BrechtSchamp
Kind of a big deal

I think your best bet is to take a look at a python training course. Lots of material can be found on the internet.

 

Now to simply get that output into a .txt or .csv you can just add " > desiredname.txt" to the command in terminal.

 

E.g.

python mypythonscript.py > desiredname.txt
Shashank
Comes here often

I am also facing same problem but only when i am trying to get all data (from all pages). But when i try it for single (current) page only by omitting out total_pages='all' then it works fine.

 

requests.exceptions.SSLError: HTTPSConnectionPool(host='n370.meraki.com', port=443): Max retries exceeded with url: /api/v1/organizations/<ORG-ID>/devices/statuses?perPage=1000&startingAfter=R2MN-1QLA-HNVB (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)')))

Get notified when there are additional replies to this discussion.