socialwifi / RouterOS-api

Python API to RouterBoard devices produced by MikroTik.
MIT License
251 stars 100 forks source link

"missing =.id=" on `poe set` on RouterOS 7.11.2 #92

Open banderlog opened 9 months ago

banderlog commented 9 months ago

Hi

When I am running this on RouterOS 7.11.2:

connection = routeros_api.RouterOsApiPool(IP, username=USER,  password=PWD, plaintext_login=True)
api = connection.get_api()
api.get_resource('/interface/ethernet/poe').call('set', {'name': port_name, 'poe-out': 'off'})

I get next error:

RouterOsApiCommunicationError: ('Error "missing =.id=" executing command b\'/interface/ethernet/poe/set =name=ether5 =poe-out=off .tag=3\'', b'missing =.id=')

With RouterOS 7.9.2 everything is fine. Please help

banderlog commented 9 months ago

Had to add ".id" key

api.get_resource('/interface/ethernet/poe').call('set', {'name': port_name, 'poe-out': 'forced-on', ".id": "*2"})

".id" COuld be obtained from api.get_resource('/interface/ethernet').call('print'):

{'id': '*1',
  'name': 'ether1',
  'default-name': 'ether1',
  'mtu': '1500',
...
banderlog commented 2 weeks ago

For RouterOs 6.49.15 (2024-Apr-24 16:04) one must use .id only. With 'name' command will just not work without any error

api.get_resource('/interface/ethernet/poe').call('set', {'poe-out': 'forced-on', ".id": "*2"})