1
General Discussion / Re: Problem with api for Unbound AddHostOverride
« on: May 02, 2022, 11:18:54 am »
Hey, i got the same problem with creating aliases (ansible + uri module)
failed: [test-opn02] (item={'name': 'TEST', 'type': 'host', 'content': ['172.18.0.21', '172.18.100.21'], 'description': 'TEST'}) => {"alias": {"content": ["172.18.0.21", "172.18.100.21"], "description": "TEST", "name": "TEST", "type": "host"}, "ansible_loop_var": "alias", "changed": false, "connection": "close", "content_length": "1555", "content_type": "application/json;charset=utf-8", "date": "Mon, 02 May 2022 09:07:56 GMT", "elapsed": 0, "json": {"errorMessage": "/usr/local/opnsense/mvc/app/controllers/OPNsense/Base/ApiControllerBase.php:155: Error at /usr/local/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/BaseField.php:345 - Array to string conversion (errno=8)", "errorTitle": "An API exception occured", "errorTrace": "#0 /usr/local/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/BaseField.php(345): OPNsense\\Base\\ApiControllerBase->APIErrorHandler(8, 'Array to string...', '/usr/local/opns...', 345, Array)\n#1 /usr/local/opnsense/mvc/app/models/OPNsense/Base/BaseModel.php(446): OPNsense\\Base\\FieldTypes\\BaseField->__toString()\n#2 /usr/local/opnsense/mvc/app/controllers/OPNsense/Base/ApiMutableModelControllerBase.php(218): OPNsense\\Base\\BaseModel->performValidation()\n#3 /usr/local/opnsense/mvc/app/controllers/OPNsense/Base/ApiMutableModelControllerBase.php(383): OPNsense\\Base\\ApiMutableModelControllerBase->validate(Object(OPNsense\\Base\\FieldTypes\\ContainerField), 'alias')\n#4 /usr/local/opnsense/mvc/app/controllers/OPNsense/Firewall/Api/AliasController.php(98): OPNsense\\Base\\ApiMutableModelControllerBase->addBase('alias', 'aliases.alias')\n#5 [internal function]: OPNsense\\Firewall\\Api\\AliasController->addItemAction()\n#6 [internal function]: Phalcon\\Dispatcher\\AbstractDispatcher->callActionMethod(Object(OPNsense\\Firewall\\Api\\AliasController), 'addItemAction', Array)\n#7 [internal function]: Phalcon\\Dispatcher\\AbstractDispatcher->dispatch()\n#8 /usr/local/opnsense/www/api.php(26): Phalcon\\Mvc\\Application->handle('/api/firewall/a...')\n#9 {main}"}, "msg": "Status code was 500 and not [200]: HTTP Error 500: Internal Server Error", "redirected": false, "server": "OPNsense", "status": 500, "url": "https://172.18.128.11/api/firewall/alias/addItem"}
any idea?
edit: solved! newline fixed it
'content': '172.18.0.21\n172.18.100.21'
failed: [test-opn02] (item={'name': 'TEST', 'type': 'host', 'content': ['172.18.0.21', '172.18.100.21'], 'description': 'TEST'}) => {"alias": {"content": ["172.18.0.21", "172.18.100.21"], "description": "TEST", "name": "TEST", "type": "host"}, "ansible_loop_var": "alias", "changed": false, "connection": "close", "content_length": "1555", "content_type": "application/json;charset=utf-8", "date": "Mon, 02 May 2022 09:07:56 GMT", "elapsed": 0, "json": {"errorMessage": "/usr/local/opnsense/mvc/app/controllers/OPNsense/Base/ApiControllerBase.php:155: Error at /usr/local/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/BaseField.php:345 - Array to string conversion (errno=8)", "errorTitle": "An API exception occured", "errorTrace": "#0 /usr/local/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/BaseField.php(345): OPNsense\\Base\\ApiControllerBase->APIErrorHandler(8, 'Array to string...', '/usr/local/opns...', 345, Array)\n#1 /usr/local/opnsense/mvc/app/models/OPNsense/Base/BaseModel.php(446): OPNsense\\Base\\FieldTypes\\BaseField->__toString()\n#2 /usr/local/opnsense/mvc/app/controllers/OPNsense/Base/ApiMutableModelControllerBase.php(218): OPNsense\\Base\\BaseModel->performValidation()\n#3 /usr/local/opnsense/mvc/app/controllers/OPNsense/Base/ApiMutableModelControllerBase.php(383): OPNsense\\Base\\ApiMutableModelControllerBase->validate(Object(OPNsense\\Base\\FieldTypes\\ContainerField), 'alias')\n#4 /usr/local/opnsense/mvc/app/controllers/OPNsense/Firewall/Api/AliasController.php(98): OPNsense\\Base\\ApiMutableModelControllerBase->addBase('alias', 'aliases.alias')\n#5 [internal function]: OPNsense\\Firewall\\Api\\AliasController->addItemAction()\n#6 [internal function]: Phalcon\\Dispatcher\\AbstractDispatcher->callActionMethod(Object(OPNsense\\Firewall\\Api\\AliasController), 'addItemAction', Array)\n#7 [internal function]: Phalcon\\Dispatcher\\AbstractDispatcher->dispatch()\n#8 /usr/local/opnsense/www/api.php(26): Phalcon\\Mvc\\Application->handle('/api/firewall/a...')\n#9 {main}"}, "msg": "Status code was 500 and not [200]: HTTP Error 500: Internal Server Error", "redirected": false, "server": "OPNsense", "status": 500, "url": "https://172.18.128.11/api/firewall/alias/addItem"}
any idea?
edit: solved! newline fixed it
'content': '172.18.0.21\n172.18.100.21'