02-19-2024 08:27 AM
hello.
I have a question and your help.
I need to upload at least 900 Meraki WPA2-Enterprise 802.1X with Meraki RADIUS users , I see that with the APIs it is possible, but only one by one, as if doing it by dashboard. can you give me a light on how to do a bulk upload from excel with the help of the APIs - Python, etc.
Thank you very much for your answers
Solved! Go to Solution.
02-20-2024 08:09 AM
Hello Phillip.
With the help of a colleague who knew python we made this code and it worked perfectly. just download the .csv in this path All the network>All the network>All the network and with that file we load the users info.
import requests
import pandas as pd
import json
excel_file_path = 'meraki_network_guests.xlsx' #Ruta donde se encuentra el archivo excel#
url = "https://api.meraki.com/api/v1/networks/IDNEtwork/merakiAuthUsers"
df = pd.read_excel(excel_file_path)
payload = '''
{
"accountType": "802.1X",
"email": "",
"name": "",
"password": "",
"emailPasswordToUser": true,
"isAdmin": false,
"authorizations": [
{
"ssidNumber": number of ssid,
"expiresAt": "Never"
}
]
}
'''
for index, row in df.iterrows():
data = json.loads(payload)
data["email"] = row['email']
data["name"] = row['name']
data["password"] = row['password']
headers = {
"Authorization": "Bearer HERE KEY",
"Content-Type": "application/json",
"Accept": "application/json"
}
response = requests.request('POST', url, headers=headers, data = json.dumps(data))
print(response.text.encode('utf8'))
02-19-2024 11:51 AM
Use a loop. Loop through all the users you want to load, and load them one at a time.
02-20-2024 08:09 AM
Hello Phillip.
With the help of a colleague who knew python we made this code and it worked perfectly. just download the .csv in this path All the network>All the network>All the network and with that file we load the users info.
import requests
import pandas as pd
import json
excel_file_path = 'meraki_network_guests.xlsx' #Ruta donde se encuentra el archivo excel#
url = "https://api.meraki.com/api/v1/networks/IDNEtwork/merakiAuthUsers"
df = pd.read_excel(excel_file_path)
payload = '''
{
"accountType": "802.1X",
"email": "",
"name": "",
"password": "",
"emailPasswordToUser": true,
"isAdmin": false,
"authorizations": [
{
"ssidNumber": number of ssid,
"expiresAt": "Never"
}
]
}
'''
for index, row in df.iterrows():
data = json.loads(payload)
data["email"] = row['email']
data["name"] = row['name']
data["password"] = row['password']
headers = {
"Authorization": "Bearer HERE KEY",
"Content-Type": "application/json",
"Accept": "application/json"
}
response = requests.request('POST', url, headers=headers, data = json.dumps(data))
print(response.text.encode('utf8'))
02-20-2024 10:05 AM
Well done!
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