help: can't add on /ip/firewall/address-list with php api

i can’t add items on /ip/firewall/address-list

$API->write(‘/ip/firewall/address-list/add’);

$API->write(‘=list=tttttttt’);

$API->write(‘=address=22.22.22.22’);



why ?

check what arguments you have to set if you end command.

in console set differently ,

in console also differently , if i write “add” he say “failure: empty list name not allowed”

if i write " add list=tttttttt address=22.22.22.22 " , then working , on api not working .

well, i have no problems running these commands:

/ip/firewall/address-list/add
=list=aaaa
=address=1.1.1.1
.tag=adr



/ip/firewall/address-list/add
=address=1.1.1.1
=list=aaaa
.tag=adr

the result:



!done
=ret=*1
.tag=adr

!done
=ret=*2
.tag=adr

so again, check if in php you do not have to indicate end of command you are running. since only last line have to be zero terminated in contrast to all other lines in the sentence. I can only get error message you get if i run:

/ip/firewall/address-list/add

as you can see without any arguments.

janisk thank you !


i parse this php cass and i find my problem ,

 *************************************************/

	function write($command, $param2 = true) {

		if ($command) {
			
			$data = explode("\n",$command);
			
			foreach ($data as $com) {
				$com = trim($com);
			        fwrite($this->socket, $this->encode_length(strlen($com) ) . $com);
			        $this->debug('<<< [' . strlen($com) . '] ' . $com);
			}

as see problem wich on definitive syntax .


so exact syntax is :

$API->write('/ip/firewall/address-list/add
				=address=9.9.9.9
				=list=55
				.tag=adr',true);

thank you again !