Hey all!
I am having a bit of trouble accessing the bluetooth settings using the dashboard API. Here is the code:
def getBluetoothSettings(network_id):
response = dashboard.bluetooth_settings.getNetworkBluetoothSettings(network_id)
print(response)
When this runs I get "DashboardAPI has no object or attribute bluetooth_settings"
Any ideas? I've tried "BluetoothSettings" as well. Additionally, I tried the v1 api and did:
def getBluetoothSettings(network_id):
response = dashboard.wireless.getNetworkBluetoothSettings(network_id)
print(response)
When this runs I get "DashboardAPI has no object or attribute wireless"
So I'm having trouble with both v0 and v1 accessing the getNetworkBluetoothSettings method
Is dashboard a global variable instantiated correctly? Also, how are you running this code? Not sure if PyCharm but I've noticed some latest updates that have changed the behavior of how the IDE finds installed modules, so try troubleshooting outside of your IDE.
This is the global variable declaration
dashboard = meraki.DashboardAPI('API_KEY_HERE')
I am running the code via the OSX terminal - python 3.7.2
Does this not work for you? Which version of Python library is installed (pip[3] show meraki)? Tested successfully with version 1.0.0b9.
import meraki
API_KEY = '6bec40cf957de430a6f1f2baa056b99a4fac9ea0' # public sandbox API key
dashboard = meraki.DashboardAPI(API_KEY)
network_id = 'L_646829496481105433'
response = dashboard.wireless.getNetworkWirelessBluetoothSettings(network_id)
print(response)
I got this traceback:
AttributeError: 'DashboardAPI' object has no attribute 'wireless'
You probably have a v0 version of the library then. See my previous message.
Name: meraki
Version: 0.110.3
Summary: Cisco Meraki Dashboard API library
Home-page: https://github.com/meraki/dashboard-api-python
Author: Cisco Meraki
Author-email: api-feedback@meraki.net
License: MIT
Location: /usr/local/lib/python3.7/site-packages
Requires: aiohttp, requests
Required-by:
How would I upgrade to the new one?
pip[3] install meraki==1.0.0b9 (b11 coming tomorrow, b10 has a silly typo/bug), via the GitHub repo
Awesome. Thank you!
Here's a simple V1 example...
btw this is using meraki 1.0.0b11
Note that the V1 API names are not the same as in V0, the one to get the Bluetooth settings for a network is...
https://developer.cisco.com/meraki/api-v1/#!get-network-wireless-bluetooth-settings
import os
import sys
import meraki
# set the key in the environment as MERAKI_DASHBOARD_API_KEY
# also define the org id in the environment
ORG_ID = os.environ.get("ORG_ID")
def main():
dashboard = meraki.DashboardAPI(
api_key='',
base_url='https://api.meraki.com/api/v1/',
print_console=False,
output_log=False,
wait_on_rate_limit=True
)
try:
networks = dashboard.organizations.getOrganizationNetworks(ORG_ID)
except meraki.APIError as e:
print(f'Meraki API error: {e}')
sys.exit(1)
except Exception as e:
print(f'some other error: {e}')
sys.exit(1)
for net in networks:
if 'wireless' in net['productTypes']:
print(net['name'])
try:
settings = dashboard.wireless.getNetworkWirelessBluetoothSettings(net['id'])
except meraki.APIError as e:
print(f'Meraki API error: {e}')
pass
except Exception as e:
print(f'some other error: {e}')
pass
else:
print(settings)
if __name__ == '__main__':
main()