OPNsense Forum

Archive => 21.1 Legacy Series => Topic started by: dym8 on June 29, 2021, 08:38:54 am

Title: Very strange API
Post by: dym8 on June 29, 2021, 08:38:54 am
Hello.

I heed to disable one of my routes by API. I run this command
Quote
curl -X POST -d '{"disabled":"1"}' -H "Content-Type: application/json" -k -u %KEY%:%SECRET% https://10.10.1.1/api/routes/routes/toggleroute/2c7375ab-2500-45a5-a952-50c34ea26b9d
and got {"result":"Disabled"}

But then I run this command again I got {"result":"Enabled"}

I run the one again and got {"result":"Disabled"}

Why? I thought I have to change command to {"disabled":"0"} for enabling. No?
Title: Re: Very strange API
Post by: franco on June 29, 2021, 01:14:14 pm
The action name is "toggleroute" which doesn't read your POST data and instead just flips the value?

You can probably also edit the route entry itself which gives you a more consistent behaviour from your perspective...


Cheers,
Franco
Title: Re: Very strange API
Post by: fabian on June 29, 2021, 07:02:11 pm
The toggle calls may support that you add /0 or /1 to the end of the URL to enable or disable the object.