10-06-2020 10:02 PM
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.
10-08-2020 05:46 PM
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)
10-06-2020 10:40 PM
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()
10-07-2020 01:38 PM
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.
10-08-2020 05:01 PM
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
10-08-2020 05:46 PM
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)
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