How to disable firewall rule? API

hello
im using java client for API and i have a problem with disabling firewall rule i put somethink like this:

ad.progTalk("/ip/firewall/filter/set\n=disabled=yes\n=.id=0");

and the response is like:

!trap
=category=0
=message=no such item
.tag=/ip/firewall/filter/set
!done

Any ideas? i think is somethink with .id ?

the documantetion for API is so small… few examples and thats all… we have to figure it all by ourselves…

PS MIKROTIK HIRE MORE PEOPLE TO DO ALL THE WORK YOU ARE DOING!!!:slight_smile:

That command should be sent as three sends. The command is sent without a terminating zero, as are all but the last line.

ad.progTalk("/ip/firewall/filter/set",false);
ad.progTalk("=disabled=yes",false);
ad.progTalk("=.id=0",true);

The false or true parameter determines if that progTalk sends the terminating zero, signaling the last of the parameters. Then ad.progListen(?) to determine the result.

can you show me yours progtalk method?

i use this one from mikrotik forum:

 public String[] progTalk(String text){
        text=text.trim();
        int counter = 0;
        String tag = "";
        if (text.contains("\n")){
            tag = text.substring(0,text.indexOf("\n"));
        } else tag = text;
        text = text.concat("\n.tag="+tag);
        String[] internalText = text.split("\n");
        while (counter < internalText.length-1){
            write(internalText[counter]);
            counter++;
        }
        writeln(internalText[counter]);
        return read();
    }

and for example with adding ip address works fine..

I see now. Your routine is fine. The writeln does the final send.
“=.id=0” is incorrect. You need to find the id with a search.
I use my own Java send routine.
Use something like this. Set the comment on the rule you want to disable to “DisableMe”, then

ad.progTalk("/ip/firewall/filter/print\n?comment=DisableMe\n=.proplist=.id");

Then use the returned “=.id=*xx” to disable the rule.

I am trying to enter this and work at the same time, so it didn’t show up all at once, and that is why. :smiley:

THANKS!!! They should employ you to make manual:)

other good chance is to use search and read how to use API at all.

Also, API is all the same for all the examples out there, so you can look on how to run one or another command. Also, i think i is mentioned that you are addressing items using .id field, later on, you can address items using name, if that argument exists. .id fields not necessary start count from zero as items are added/deleted and numbers increase. With dynamic item numbering being even further from 0.