05-18-2021 05:37 AM
Hi,
i am looking for a possibility to query the username of a guest account not the User ID.
I have the following code where i get all users, but i can not find or filter a specific User by filtering the username (mail address) maybe someone can help getting the meraki_auth_user_id by filtering the mail address?
import meraki
API_KEY = 'xxxxxxxxxxxxxx'
dashboard = meraki.DashboardAPI(API_KEY)
network_id = 'xxxxxxxxxxxxxxx'
response = dashboard.networks.getNetworkMerakiAuthUsers(
network_id
)
print (response)
As result, i need the ID of the User by searching after the mail address.
Thanks for any help or advise.
Dennis
Solved! Go to Solution.
05-18-2021 10:56 AM
The most obvious way is to loop thru the user list:
import meraki
API_KEY = 'xxxxxxxxxxxxxx'
dashboard = meraki.DashboardAPI(API_KEY)
network_id = 'xxxxxxxxxxxxxxx'
required_username = 'myuser@name.com'
users = dashboard.networks.getNetworkMerakiAuthUsers(
network_id
)
for user in users:
if user["email"] == required_username:
pprint(user)Pythonic way would be to substitute the for loop with list comprehension:
myuser = [user for user in users if user["email"]==required_username]
pprint(myuser)
05-18-2021 10:56 AM
The most obvious way is to loop thru the user list:
import meraki
API_KEY = 'xxxxxxxxxxxxxx'
dashboard = meraki.DashboardAPI(API_KEY)
network_id = 'xxxxxxxxxxxxxxx'
required_username = 'myuser@name.com'
users = dashboard.networks.getNetworkMerakiAuthUsers(
network_id
)
for user in users:
if user["email"] == required_username:
pprint(user)Pythonic way would be to substitute the for loop with list comprehension:
myuser = [user for user in users if user["email"]==required_username]
pprint(myuser)
05-26-2021 07:10 AM
Perfect, Thank you so much ! 🙂
It works great!
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