I'm trying to modify Zabbix triggers via it's API, but it doesn't allow me to neither update the triggers with API method "trigger.update" nor to delete the triggers with API method "trigger.delete".
I've managed to create, update and delete Host Groups, Hosts and Templates with no problem with Zabbix API, but as I've said above, I can't change triggers, and can't find out the reason.
When I try to delete the trigger with these parameters (so I could recreate it again with new values), Zabbix API returns me with the following error:
{"jsonrpc":"2.0","method":"trigger.delete","id":1,"auth":"token","params":["XXXX"]}
Cannot delete templated trigger "MyTriggerName:{SomoHostName:ItemName.regexp(^OK)}<>1".
And when I try to update the trigger with following parameters, Zabbix API returns this other error:
{"jsonrpc":"2.0","method":"trigger.update","id":1,"auth":"token","params":{"triggerid":"XXX","status":0,"expression":"{TemplateName:ItemName.regexp(^OK)}<>1"}}
error.message: Invalid params.
error.data: Cannot update "expression" for templated trigger "TriggerName".
So, the error messages both for update and delete operations complaint about something related to "templated trigger". I want to modify the triggers globally, so that the changes may be applied in all hosts which have the trigger template linked to it.
Can someone point out what may be the reason why Zabbix is not allowing me to neither update nor delete triggers? Thanks a lot.
First, note that this is not a REST API, but a JSON-RPC one.
Second, your problem is that you are using the trigger ID of a templated trigger - that is, one on a host and coming from a template. If you would try to delete such a trigger in the Zabbix frontend, you would get the same error message.
As you say that you want to update it on the template, the solution is to use the trigger ID for the trigger on the target template.