HI All,
When I applied the script for replacing "RADIUS Servers", I encountered the following error code. However, It is working as expected on the "Sandbox".
Updated RADIUS server radius1 for SSID ONE-1900
Updated RADIUS server radius2 for SSID ONE-1900
Updated RADIUS server radius3 for SSID ONE-1900
Failed to update SSID configuration for ONE-1900. Status code: 400
Script:-
import requests
# Define your API key, network ID, and base URL
API_KEY = 'YOUR_API_KEY'
NETWORK_ID = 'YOUR_NETWORK_ID'
BASE_URL = 'https://api.meraki.com/api/v1'
# Define the old and new radius server values
OLD_RADIUS_SERVERS = {
'radius1': 'OLD_RADIUS_SERVER_IP_1',
'radius2': 'OLD_RADIUS_SERVER_IP_2',
'radius3': 'OLD_RADIUS_SERVER_IP_3'
}
NEW_RADIUS_SERVERS = {
'radius1': 'NEW_RADIUS_SERVER_IP_1',
'radius2': 'NEW_RADIUS_SERVER_IP_2',
'radius3': 'NEW_RADIUS_SERVER_IP_3'
}
# Define headers with API key
headers = {
'X-Cisco-Meraki-API-Key': API_KEY,
'Content-Type': 'application/json'
}
# Function to update RADIUS server configuration
def update_radius_config(ssid_config):
# Check if RADIUS servers are configured
if 'radiusServers' in ssid_config:
radius_servers = ssid_config['radiusServers']
updated = False
for server in radius_servers:
for old_name, old_host in OLD_RADIUS_SERVERS.items():
if server['host'] == old_host:
new_host = NEW_RADIUS_SERVERS[old_name]
server['host'] = new_host
updated = True
print(
f"Updated RADIUS server {old_name} for SSID {ssid_config['name']}"
)
if updated:
# Make a PUT request to update the SSID configuration
ssid_config_url = f"{BASE_URL}/networks/{NETWORK_ID}/wireless/ssids/{ssid_config['number']}"
put_response = requests.put(ssid_config_url,
json=ssid_config,
headers=headers)
if put_response.status_code == 200:
print(
f"SSID configuration updated successfully for {ssid_config['name']}"
)
else:
print(
f"Failed to update SSID configuration for {ssid_config['name']}. Status code: {put_response.status_code}"
)
# Get SSIDs of the network
url = f"{BASE_URL}/networks/{NETWORK_ID}/wireless/ssids"
response = requests.get(url, headers=headers)
if response.status_code == 200:
ssids = response.json()
for ssid in ssids:
update_radius_config(ssid)
else:
print("Failed to retrieve SSIDs.")