Hi, I have a host created via API (host.create) including 5 initial tags.
I'm trying to add a new tag for a host, but the API host.update replaces all the 5 old tags with the new one. So instead of having 6 tags, the host ended up with only 1.
Any suggestions to add a new tag via APIs?
zabbix_server (Zabbix) 6.2.1
Call:
url='http://'+ zbxServer +'/zabbix/api_jsonrpc.php';
Also, I tried to use host.get with "selectTags": "extend", but it brings the tags with an "automatic": "0" in each tag, i.e:
when I added the new tag to the existing tags returned by host.get, and try to host.update it I'm receiving the error:
Thanks
I'm trying to add a new tag for a host, but the API host.update replaces all the 5 old tags with the new one. So instead of having 6 tags, the host ended up with only 1.
Any suggestions to add a new tag via APIs?
zabbix_server (Zabbix) 6.2.1
Call:
url='http://'+ zbxServer +'/zabbix/api_jsonrpc.php';
Code:
host.update:
data={
"jsonrpc": "2.0",
"method": "host.update",
"params": {
"hostid": hostid,
"tags": [ {
"tag": "deactivated",
"value": deactivationDate
}]
},
"auth": token,
"id": 1
}
Code:
host.get result:
"tags": [
{
"tag": "type",
"value": "server",
"automatic": "0"
},
...
...
{
"tag": "service",
"value": "active",
"automatic": "0"
}
]
when I added the new tag to the existing tags returned by host.get, and try to host.update it I'm receiving the error:
Code:
Reading : [{'tag": "type","value": "server", "automatic": "0"},.....{"tag":"service","value":"active","autom atic":"0"}]
Appending: [{'tag": "type","value": "server", "automatic": "0"},.....{"tag":"service","value":"active","autom atic":"0"},
{"tag": "deactivated", "value": "2022-08-26 20:51:53"}
]
host.update result:
Error: {'jsonrpc': '2.0',
'error':{'code': -32602, 'message': 'Invalid params.', 'data': 'Invalid parameter "/1/tags/1": unexpected parameter "automatic".'},
'id': 1}
Comment