Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Yves.degauquier

#1
Hi,
I try to use the API to manage the Unbound DNS by adding new host override.
On this topic Google was not my friend.
I found the API but I still have issue on how to feed the API with data :(.

curl -X POST -d '{"host":{"enabled":"1","hostname":"test","domain":"testdomain.com","rr":{"A":{"value":"A (IPv4 address)","selected":1},"AAAA":{"value":"AAAA (IPv6 address)","selected":0},"MX":{"value":"MX (Mail server)","selected":0}},"mxprio":"","mx":"","server":"10.0.1.1","description":""}}' -H "Content-Type: application/json" -k -u $OPNS_KEY:$OPNS_SECRET https://$IPFW/api/unbound/settings/AddHostOverride

The result is:
{"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)","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), 'host')\n#4 /usr/local/opnsense/mvc/app/controllers/OPNsense/Unbound/Api/SettingsController.php(142): OPNsense\\Base\\ApiMutableModelControllerBase->addBase('host', 'hosts.host')\n#5 [internal function]: OPNsense\\Unbound\\Api\\SettingsController->addHostOverrideAction()\n#6 [internal function]: Phalcon\\Dispatcher\\AbstractDispatcher->callActionMethod(Object(OPNsense\\Unbound\\Api\\SettingsController), 'addHostOverride...', Array)\n#7 [internal function]: Phalcon\\Dispatcher\\AbstractDispatcher->dispatch()\n#8 /usr/local/opnsense/www/api.php(26): Phalcon\\Mvc\\Application->handle('/api/unbound/se...')\n#9 {main}","errorTitle":"An API exception occured"}

Does someone can give me some hints?

Thanks in advance :-)