[ZBX-7278] API host.massremove templateids_clear generates SQL error Created: 2013 Nov 05  Updated: 2017 May 30  Resolved: 2013 Nov 06

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: API (A)
Affects Version/s: 2.0.8
Fix Version/s: None

Type: Incident report Priority: Minor
Reporter: Gregory Ruiz-Ade Assignee: Ivo Kurzemnieks
Resolution: Duplicate Votes: 0
Labels: api
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Oracle Enterprise Linux 6.4, Zabbix RPMs from Zabbix repository


Issue Links:
Duplicate
duplicates ZBX-3783 Proper API validation Reopened

 Description   

Attempting to do a template "unlink and clear" via the API fails. Performing the operation manually (via the Web UI) works as expected.

Request:

{
"method": "host.massremove",
"params": {
"hostids": [
"10141"
],
"templateids_clear":

{ "templateid": [ "10983" ] }

},
"auth": "8f0b53cfa9d56d8e65533d60d763bcef",
"id": 73983,
"jsonrpc": "2.0"
}

Response:

{ "code": -32500, "message": "Application error.", "data": "SQL statement execution has failed \"DELETE FROM hosts_templates WHERE templateid=Array AND hostid='10141'\"" }

 Comments   
Comment by Ivo Kurzemnieks [ 2013 Nov 06 ]

The given API request is incorrect. There is no need for another array 'templateid'. See documentation for 2.0 and 2.2.
In request 'templateids_clear' can be either array:

{
    "hostids": [
        "10122"
    ],
    "templateids_clear": [
        "10056"
    ]
}

or string:

{
    "hostids": [
      "10122"
    ],
    "templateids_clear": "10056"
}

Nowever API requires additional validation for such cases, but this will be fixed under ZBX-3783.
Closing as duplicate.

Generated at Tue Apr 29 00:22:30 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.