- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Error while trying to import Meraki __init__ raise APIKeyError()
I'm trying to import Meraki and get error of __init__ raise APIKeyError()
Here is the script I'm using
MERAKI_DASHBOARD_API_KEY='093b24e85df15a3e66f1fc359f4c48493eaa1b73' # Demo API Key
import meraki
dashboard = meraki.DashboardAPI()
my_orgs = dashboard.organizations.getOrganizations()
Here is where it fails
# Check API key
api_key = api_key or os.environ.get(API_KEY_ENVIRONMENT_VARIABLE)
if not api_key:
raise APIKeyError()
Here is the output
C:\Users\MerakiAppData\Local\Programs\Python\Python38\Lib\site-packages\meraki\__init__.py", line 61, in __init__
raise APIKeyError()
meraki.exceptions.APIKeyError: Meraki API key needs to be defined
Any help would be apricated in advance.
Solved! Go to solution.
- Labels:
-
Dashboard API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I figured out what the problem was. I wasn't passing the api_key into the argument.
dashboard = meraki.DashboardAPI()
should have been dashboard = meraki.DashboardAPI(api_key)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Correction to my post
I ran each line into the python console and it isn't failing in the import Meraki. It is failing when it calls dashboard = meraki.DashboardAPI()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
MERAKI_DASHBOARD_API_KEY='093b24e85df15a3e66f1fc359f4c48493eaa1b73' # Demo API Key
...
api_key = api_key or os.environ.get(API_KEY_ENVIRONMENT_VARIABLE)
You have defined a variable called MERAKI_DASHBOARD_API_KEY and then referenced api_key.
You could perhaps use:
api_key = MERAKI_DASHBOARD_API_KEY or os.environ.get(API_KEY_ENVIRONMENT_VARIABLE)
or:
api_key = 093b24e85df15a3e66f1fc359f4c48493eaa1b73'
instead of using MERAKI_DASHBOARD_API_KEY.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the reply
However I get the same error
Code
pi_key='093b24e85df15a3e66f1fc359f4c48493eaa1b73' # Demo API Key
import meraki
dashboard = meraki.DashboardAPI()
File "C:\Users\Meraki\AppData\Local\Programs\Python\Python38\Lib\site-packages\meraki\__init__.py", line 61, in __init__
raise APIKeyError()
meraki.exceptions.APIKeyError: Meraki API key needs to be defined
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I figured out what the problem was. I wasn't passing the api_key into the argument.
dashboard = meraki.DashboardAPI()
should have been dashboard = meraki.DashboardAPI(api_key)
