not able to change bandwidth on the fly using API

Hello,

I have coded a program in java to change pppoe user bandwidth on the fly via java API. when i use “/ip/address/print” command it give proper output, but when i try to update the user bandwidth with command “/queue/simple/set/numbers=[/queue/simple/find/where =name =""] =max-limit="2048k"” . it gives “!trap =message=no such command”.

Thanks in advance.

  1. There’s no “find” command in API.
  2. There’s no “where” argument in API.
  3. There’s no support for “nested” commands.
  4. Arguments are written as separate words in form of “=name=value”, without quotes, and this includes the “numbers” argument.

To do setting, you need to do “print” request, with a query that matches what you want, get the ID, and pass that to the “numbers” argument of the “set” command.

With simple queues in particular though, you can actually skip the print request - just use the queue’s name instead of its ID. Like:

/queue/simple/set
=numbers=<pppoe-t1>
=max-limit=2048k

Again: These need to be written as separate API words, part of the same API sentence.

Thanks for your response.

I have tried to send the message to mikrotik as you mentioned.
Following command i send.

ret.sendCommand(“/queue/simple/set”);
ret.sendCommand(“=numbers=”);
ret.sendCommand(“=max-limit=512K/512K”);

I get the reply “!done”. but max-limit of user is not getting changed.

Is this the JAVA client?

With that client, the full sentence needs to be written out in the first argument, using new lines, like:

ret.sendCommand("/queue/simple/set\n=numbers=<pppoe-t1>\n=max-limit=512K/512K");

(BTW, this is violation of the API protocol, and you’ll find it problematic in some scenarios… but that’s what this flawed client supports)

API protocol states how the communication have to be done over the network. On the other hand, it is possible to use other methods provided to send as you would like - one command at a time, however, if you are not setting scripts up then this approach results in less packages sent over the network (and that was important for me when i wrote it)

its working fine with

ret.sendCommand("/queue/simple/set\n=numbers=<pppoe-t1>\n=max-limit=512K/512K");

Thanks boen_robot and all of you to view the post and provide suggestions.