When making calls against the `template.massAdd` endpoint, the API returns no error when run with nil values
For example, using the zabbixapi gem:
require "zabbixapi" zbx = ZabbixApi.connect( :url => 'http://localhost/zabbix/api_jsonrpc.php', :user => 'Admin', :password => 'zabbix' ) result = zbx.api_request( :method => "template.massAdd", :params => { :hosts => data[:hosts_id].map { |t| {:hostid => t} }, :templates => data[:templates_id].map { |t| {:templateid => t} } } ) puts result {"templateids"=>[]}
If you specifically give template_ids or host_ids that don't exist, an error is raised as expected:
data[:hosts_id] = ['1'] data[:templates_id] = ['1'] result = @client.api_request( :method => "template.massAdd", :params => { :hosts => data[:hosts_id].map { |t| {:hostid => t} }, :templates => data[:templates_id].map { |t| {:templateid => t} } } ) puts result ZabbixApi::ApiError: Server answer API error { "code": -32500, "message": "Application error.", "data": "No permissions to referred object or it does not exist!" } on request: { "method": "template.massAdd", "params": { "hosts": [ { "hostid": "1" } ], "templates": [ { "templateid": "1" } ] }, "id": 93168, "jsonrpc": "2.0", "auth": "3047835e2bd5be76b69e053724f9baf4" }
This appears to be a bug with Zabbix upstream rather than the gem.
Expected behaviour:
Zabbix returns Application error when given no IDs for server_id or template_id
- part of
-
ZBX-3783 Proper API validation
- Reopened