I did research through the wikis, manuals,forums and so on, but still couldn’t find the answer. I want to query single parameter value through the API, but still always receiving mess of tons of parameters. In human query I need:
Get value of security profile ID by security profile name.
Get name of wireless security profile by specific ID.
So on…
As I understood from manual, I am sending:
/interface/wireless/security-profiles/getall
or
/interface/wireless/security-profiles/print
and providing some query arguments for output filtering
?name=DEV
As a result taking ALL parameters for profile DEV, i would like to receive ONE parameter by it’s name provided somewhere in query.
In RouterOS v6.0 and later, you can also use the the “get” command, similarly as you do from terminal, except that you need to explicitly use the argument names, e.g.
Note also that, as the example above shows, when the menu you’re targeting uses names, you don’t have to use the ID - you can just use the name directly.
If you want to read several properties of an item at once OR read all items’ property of that kind, it’s still more efficient to use “print” with “.proplist”, as skot shows above.
They do say that the API closely follows the command line… So this was supposed to be there from day 1, but it wasn’t. In earlier versions, get just returns an empty !done, and that’s it.
The place where this change should’ve been present is not the wiki, but the change logs, and we all know how complete those tend to be.
When you open up a terminal, type the command, and then type “?”.
You’ll see
<number>
as part of the “get” output.
“number”, as well as any argument written with “<” and “>” as above, is an unnamed argument. An argument with a name that can be omitted when using CLI. With the API though, you can’t omit it - you must specify it, always.