-
Problem report
-
Resolution: Unresolved
-
Trivial
-
None
-
7.0.4
-
None
Using zabbix_utils Python library to add tag to a host "Testhost":
>>> from zabbix_utils import ZabbixAPI >>> zapi = ZabbixAPI(url="https://zabbix.example.com/zabbix") >>> zapi.login(token="xxxyyyzzz") >>> zapi.version 7.0.4 >>> host = zapi.host.get(filter={"host":"Testhost"}, selectTags="extend")[0] >>> tags = host["tags"] # Existing tag: >>> tags [{'tag': 'tag1', 'value': 'value1', 'automatic': '0'}] >>> # Now add another tag: >>> tags.append({"tag": "tag2", "value": "value2"}) >>> tags [{'tag': 'tag1', 'value': 'value1', 'automatic': '0'}, {'tag': 'tag2', 'value': 'value2'}] >>> zapi.host.update({"hostid": host["hostid"], "tags": tags}) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/markku/temp/zabbix_utils/venv/lib/python3.11/site-packages/zabbix_utils/api.py", line 90, in func return self.parent.send_api_request( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/markku/temp/zabbix_utils/venv/lib/python3.11/site-packages/zabbix_utils/api.py", line 376, in send_api_request raise APIRequestError(err) zabbix_utils.exceptions.APIRequestError: Invalid params. Invalid parameter "/1/tags/1": unexpected parameter "automatic". >>>
Error message: Invalid params. Invalid parameter "/1/tags/1": unexpected parameter "automatic".
Workaround:
Remove the "automatic" values from the tag list before updating the host:
>>> for tag in tags: ... tag.pop("automatic", None) ... '0' >>> tags [{'tag': 'tag1', 'value': 'value1'}, {'tag': 'tag2', 'value': 'value2'}] >>> zapi.host.update({"hostid": host["hostid"], "tags": tags}) {'hostids': ['12345']} >>>