A script I've had in production to change the PSK on a specific SSID weekly, and which has been working flawlessly week-in week-out for over 3 years, suddenly stopped working over the weekend, returning a "400: Bad Request" message, indicating some issue with the json or parameters. The script is powershell, using the Invoke-RestMethod cmdlet.
Has something changed in the ability to set a PSK on an SSID, or something in the API preventing my PUT statement from working any longer? Relevant code snippets below.
$randomkey = 'PSK'
$api_key = '************************************************'
function Put-GuestWiFiPSK {
$header = @{
"X-Cisco-Meraki-API-Key" = "$api_key"
"Content-Type" = 'application/json'
}
$api = @{
"endpoint" = 'https://n***.meraki.com/api/v0'
}
$psk = @{
"number" = "2"
"name" = "******** WiFi Network"
"splashPage" = "Click-through splash page"
"ssidAdminAccessible" = "False"
"authMode" = "psk"
"psk" = "$randomkey"
"encryptionMode" = "wpa"
"wpaEncryptionMode" = "WPA1 and WPA2"
"ipAssignmentMode" = "Bridge mode"
"defaultVlanId" = "421"
"walledGardenEnabled" = "False"
"minBitrate" = "1"
"bandSelection" = "Dual band operation"
"perClientBandwidthLimitUp" = "0"
"perClientBandwidthLimitDown" = "0"
}
$json = $psk | ConvertTo-Json
$api.url = '/organizations/********/networks/****************/ssids/2'
$uri = $api.endpoint + $api.url
$request = Invoke-RestMethod -Method PUT -Uri $uri -Headers $header -Body $json
return $request
}