OPNsense Forum

English Forums => 26.7 Series => Topic started by: Webfeger on September 18, 2026, 07:28:59 PM

Title: API reauest toggleRule failed
Post by: Webfeger on September 18, 2026, 07:28:59 PM
Hi there,

i try to toggle fw rules by pusing api request in powershell. I already tried to check out different sites but i can't find the reason, why this request failed:

# api key
$key = 'hidden'
# api secret
$secret = 'hidden too' 
# url
$url = 'https://192.168.1.1:4444' 
# ------------------

# create basic auth info
$authinfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $key,$secret))) 
Invoke-RestMethod -Uri "$url/api/firewall/filter/toggleRule/getRule/d4649c5b-8e6c-4768-88fd-6f39a28e0a05/0" -Method Post -Headers @{Authorization = "Basic $authinfo"} 

Output:
result
------
failed


Any ideas?
I already checked out that the UUID is correct by using backup xml
Title: Re: API reauest toggleRule failed
Post by: Webfeger on September 18, 2026, 09:00:58 PM
Sometimes you can't see the forest for the trees. It only just occurred to me that an error had crept into the URL.. the script is working without the getRule param..