In the following example JSON the inventory is provided as an array in stead of an object.
This breaks CHost->create() in:
if (isset($host['inventory']) && !empty($host['inventory'])) { $fields = array_keys($host['inventory']); $fields[] = 'inventory_mode'; $fields = implode(', ', $fields); $values = array_map('zbx_dbstr', $host['inventory']); $values[] = isset($host['inventory_mode']) ? $host['inventory_mode'] : HOST_INVENTORY_MANUAL; $values = implode(', ', $values); DBexecute('INSERT INTO host_inventory (hostid, '.$fields.') VALUES ('.$hostid.', '.$values.')'); }
DBexecute fails because $fields and $values contain: "0, Array" instead of the data that's provided in the inventory array.
An error should be thrown here.
Example JSON
{ "jsonrpc": "2.0", "method": "host.create", "params": { "host": "example.tld", "name":"example", "interfaces": [ { "type": 2, "main": 1, "useip": 0, "ip": "192.0.2.1", "dns": "example.tld", "port": "161" } ], "groups": [ { "groupid": "200200000000014" } ], "templates": [ { "templateid": "200200000010086" } ], "inventory": [ { "macaddress_a": "01234" } ] }, "auth": "95c673430adb1644fdc6734e602988ec", "id": 1 }