cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Meraki Python API error

Highlighted
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 \\?

11 REPLIES 11
Highlighted
Kind of a big deal

Re: Meraki Python API error

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

Highlighted
A model citizen

Re: Meraki Python API error

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!

Highlighted
Kind of a big deal

Re: Meraki Python API error

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

Highlighted
A model citizen

Re: Meraki Python API error

Fair enough, then. 🙂
Highlighted
Comes here often

Re: Meraki Python API error

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

Highlighted
New here

Re: Meraki Python API error

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?

Highlighted
Comes here often

Re: Meraki Python API error

was going to reply that. haha

Highlighted
Kind of a big deal

Re: Meraki Python API error

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

Highlighted
Kind of a big deal

Re: Meraki Python API error

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.

Highlighted
Comes here often

Re: Meraki Python API error

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.

 

Highlighted
Kind of a big deal

Re: Meraki Python API error

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
Welcome to the Meraki Community!
To start contributing, simply sign in with your Cisco account. If you don't yet have a Cisco account, you can sign up.