Hello everybody
Sorry,for my average englsih.
I try to delete addresses ip since a button “suppr” by means of the library tik4net in c#.
The code is the following one:
private void button_suppr_Click(object sender, EventArgs e)
{
using (TikSession session = new TikSession(TikConnectorType.Api))
{
session.Open(“ip”, “login”, “passwd”);
IApiConnector apiConnector = (IApiConnector)session.Connector;
apiConnector.ApiExecute(“/ip/address/remove”,
new Dictionary<string, string>
{
{“numbers”,“*8”}
});
textBox1_recupInfo.Text = “blabla”;
}
}
I have a concern I do not manage to get id of an address ip I would like to know how we make.
command?
thanks ,best regards.
First:
the right syntax of the command:
replace to the address to be deleted
/ip address remove [ find where address=> > ]
thanks for quick answer.
I test this command in winbox.
Winbox said :
remove [find where address=<192.168.10.125/24>]
invalid value for argument address
address enter is valid.
I put only address not netmak and interface.?
I said nothing i understand sorry
thanks
it’s work in winbox but in my code no
using (TikSession session = new TikSession(TikConnectorType.Api))
{
session.Open(“192.168.10.100”, “admin”, “admin”);
IApiConnector apiConnector = (IApiConnector)session.Connector; //!!! MOST important row in sample
apiConnector.ApiExecute(“/ip address remove [find where address=192.168.10.170]”,
new Dictionary<string, string>
{
/* {“numbers”,“<3>”}*/
});
textBox1_recupInfo.Text = “blabla”;
}
idea?
You need to do “/ip/address/print” with a query. That’s the equivalent of CLI’s “where” argument.
How exactly do you do that using tik4net, I’m not sure.
boen_robot:
You need to do “/ip/address/print” with a query. That’s the equivalent of CLI’s “where” argument.
How exactly do you do that using tik4net, I’m not sure.
“/ip address remove [find where address=192.168.10.170]” API equivalent = “/ip/address/print”???
I do not think…
It’s an equivalent of the
find where address=192.168.10.170
part, not the “remove” part.
In protocol flow terms:
/ip/address/print
.proplist=.id
?address=192.168.10.170
!re
=.id=*8
!done
Once the ID is retrieved, it’s on to the thing that happened in the original post - supplying the ID at the “numbers” argument.
There is no way to exec on API directly this command:
“/ip/address/remove=number=[/ip/address/find/where=address=192.168.10.170]”
?
Remember: i not know API.
Thanks for your answer.
Now, I want study the API only for implement ros_exec(“any normal script command here”) like on The Dude…
Thanks for your solution boen.
I get id ip with your solution like this :
foreach (ITikEntityRow row in canList)
{
idrec = row.GetStringValueOrNull(“.id”, true);
ip1 = row.GetStringValueOrNull(“address”, true);
network = row.GetStringValueOrNull(“network”, true);
interfac = row.GetStringValueOrNull(“interface”, true);
}
The most important is the name key “.id” , this key allow get id of item.
then i post in my listview .
thanks everybody for your answer.