OPNsense
  • Home
  • Help
  • Search
  • Login
  • Register

  • OPNsense Forum »
  • Archive »
  • 21.1 Legacy Series »
  • Very strange API
« previous next »
  • Print
Pages: [1]

Author Topic: Very strange API  (Read 1392 times)

dym8

  • Newbie
  • *
  • Posts: 13
  • Karma: 1
    • View Profile
Very strange API
« 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?
Logged

franco

  • Administrator
  • Hero Member
  • *****
  • Posts: 17751
  • Karma: 1620
    • View Profile
Re: Very strange API
« Reply #1 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
Logged

fabian

  • Hero Member
  • *****
  • Posts: 2769
  • Karma: 200
  • OPNsense Contributor (Language, VPN, Proxy, etc.)
    • View Profile
    • Personal Homepage
Re: Very strange API
« Reply #2 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.
Logged

  • Print
Pages: [1]
« previous next »
  • OPNsense Forum »
  • Archive »
  • 21.1 Legacy Series »
  • Very strange API
 

OPNsense is an OSS project © Deciso B.V. 2015 - 2024 All rights reserved
  • SMF 2.0.19 | SMF © 2021, Simple Machines
    Privacy Policy
    | XHTML | RSS | WAP2