I am trying to update the MX L7 firewall rules and am getting a 400 Bad Request. If I compare what my variable looks like that I am using to do the update via the API to what it looks like if I update it in the dashboard and get the rules it appears to be the same. Below it the main part of the code. It reads through the existing rules and if the rule I need isn't there is adds it. Same issue with V0 or V1; this code is currently using V1. #Check and create MX - Layer 7 Firewall Rules $FW = Get_Meraki("https://dashboard.meraki.com/api/v1/networks/" + $Network.id + "/appliance/firewall/l7FirewallRules") $Bit_Exist = $false foreach ($Rule in $FW.rules) { if ($Rule.policy -eq "deny" -and $Rule.type -eq "application" -and $Rule.value.id -eq "meraki:layer7/application/110" -and $Rule.value.name -eq "BitTorrent") { $Bit_Exist = $true } } if ( $Bit_Exist -eq $false ) { $New_Rule = @() $New_Rule = "" | Select policy,type,value $New_Rule.policy = "deny" $New_Rule.type = "application" $Value_Rule = @() $Value_Rule = "" | Select id,name $Value_Rule.id = "meraki:layer7/application/110" $Value_Rule.name = "BitTorrent" $New_Rule.value = $Value_Rule $FW.rules += $New_Rule #PUT/networks/{networkId}/appliance/firewall/l7FirewallRules $json = $FW | ConvertTo-Json $UpdateURL = "https://" + $Shard + ".meraki.com/api/v1/networks/" + $Network.id + "/appliance/firewall/l7FirewallRules" #Update Meraki Start-Sleep -m 300 Try { $response = Invoke-RestMethod $UpdateURL -Method Put -Body $json -Headers $headers -ContentType 'application/json' } Catch { $_.Exception "Error" } }
... View more