load many 802.1x users

Solved
Ruben_Rios
Conversationalist

load many 802.1x users

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

1 Accepted Solution

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'))

 

 

View solution in original post

3 Replies 3
PhilipDAth
Kind of a big deal
Kind of a big deal

Use a loop.  Loop through all the users you want to load, and load them one at a time.

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'))

 

 

Well done!

Get notified when there are additional replies to this discussion.