Community discussions

MikroTik App
 
lory
just joined
Topic Author
Posts: 2
Joined: Thu Jan 10, 2019 2:42 pm

REST API - get status of rule

Sat Sep 17, 2022 1:28 pm

Hello, I want to get status of firewall rule with rest api.

With ssh i can do it:
ssh 10.0.0.1 '/put [/ip/firewall/raw/get [find where src-mac-address="64:FF:0A:CD:DA:12"] disabled]'
false

If this is imposible, i have script wich returns status ot rule, but i can not execute script via rest api and get output.

Please help.
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7038
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: REST API - get status of rule

Mon Sep 19, 2022 3:23 pm

 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: REST API - get status of rule  [SOLVED]

Mon Sep 19, 2022 4:09 pm

:put ([/tool fetch url="https://192.168.88.1/rest/ip/firewall/raw?src-mac-address=64:FF:0A:CD:DA:12&.proplist=disabled" \
     user=admin password="" as-value output=user]->"data")

You have as result something like
[{".id":"*1","disabled":"false"}]
or
[{".id":"*1","disabled":"true"}]
 
lory
just joined
Topic Author
Posts: 2
Joined: Thu Jan 10, 2019 2:42 pm

Re: REST API - get status of rule

Tue Sep 20, 2022 6:06 pm

It is working.

Thanks :D

Who is online

Users browsing this forum: NxtGen [Bot] and 15 guests