I am trying to execute a PUT script in PS, below is the function. When I run the script I'm receiving a 308 error.
[Net.ServicePointManager]:: SecurityProtocol = [Net.SecurityProtocolType]::Tls12
#Change Guest Wifi Password
$MerakiApiKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
$NETWORK_ID = "XXXXXXXXXXXXXXXX"
$MerakiUrl = "https://dashboard.meraki.com/api/v0/networks/$NETWORK_ID/ssids/6"
$headers = @{}
$headers.Add("X-Cisco-Meraki-API-KEY",$MerakiApiKey)
$headers.Add("ContentType",'application/json')
$jbody = '{"psk": "NewPassword"}'
Invoke-RestMethod -Method put -Uri $MerakiUrl -Headers $headers -Body $jbody
When I run the above script I receive the below.
Invoke-RestMethod : The remote server returned an error: (308).
At line:9 char:1
+ Invoke-RestMethod -Method put -Uri "https://dashboard.meraki.com/api/ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
I have tried testing the functionality of the PUT command in POSTMAN and it works flawlessly. I know the documentation says to use https://api.meraki.com/api/v0/ as the base url but when i change the url to that, the script still fails with the same error.
I tried capturing the response I get back using the below code:
$resp = try { Invoke-RestMethod -Method put -Uri $MerakiUrl -Headers $headers -Body $jbody } catch { $_.Exception.Response }
$resp
Here is the output of the above:
Any insight would great.