I am using the following PowerShell code to attempt to create a Third Party VPN Peer in a Meraki organization. [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$api_key = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
$header = @{
"X-Cisco-Meraki-API-Key" = $api_key
"Content-Type" = 'application/json ; charset=utf-8'
}
$orgID = 'YYYYYYYYYYYYYYYYY'
$api = @{
"endpoint" = 'https://nZZ.meraki.com/api/v0'
}
$api.url = '/organizations/' + $orgID + '/thirdPartyVPNPeers'
$uri = $api.endpoint + $api.url
$parms = [ordered]@{
name = "VPN-PEER-NAME"
publicIp = "1.1.1.1"
privateSubnets = @(
"10.0.1.1/32"
)
secret = "WWWWWWWWWWWWWWWWWWWWW"
ipsecPolicies = @{
ikeCipherAlgo = "aes256"
ikeAuthAlgo = "sha1"
ikeDiffieHellmanGroup = "group2"
ikeLifetime = "28800"
childCipherAlgo = "aes256"
childAuthAlgo = "sha1"
childPfsGroup = "disabled"
childLifetime = "3600"
}
}
$json = $parms | ConvertTo-Json
$change = Invoke-RestMethod -Method Put -Uri $uri -Body $json -Headers $header
$change
Once I run that, I get the following error: Invoke-RestMethod : The remote server returned an error: (400) Bad Request.
At line:58 char:11
+ $change = Invoke-RestMethod -Method Put -Uri $uri -Body $json -Header ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand I was thinking that perhaps my json is incorrect. I've tried numerous different approaches to format it. I am following this link for direction on the construction of the calls: https://documenter.getpostman.com/view/897512/meraki-dashboard-api/2To9xm#c2d0ec2c-b1e9-4eaa-83eb-cf06119cd0c9 Now, I do note that this says "update" and not "create". So, that may be the issue as well....
... View more