Hi everybody,
I have a Zabbix 1.8.4 deployment, and lately I've been struggling to create an action from the API, in which the operations use only an specific media type. The example in the API documentation looks like this:
As you can see, the mediatypeid is passed inside a parameter called opmediatypes, which is in turn an array. However, it didn't work; it seemed like the parameter opmediatypes was ignored.
After hacking a bit around the code of the frontend, I realized that the correct way to create an action like I wanted was:
That's it. Just pass mediatypeid as one more parameter in the operation object.
However, I warn you that if you use action.get to retrieve the action you've just created, you will receive an object like this:
Yes, the mediatypeid is again inside opmediatypes array.
I share this recipe with you because it's a bit obscure. Maybe it could be thought it's a bug, isn't it?
I have a Zabbix 1.8.4 deployment, and lately I've been struggling to create an action from the API, in which the operations use only an specific media type. The example in the API documentation looks like this:
Code:
{
"jsonrpc":"2.0",
"method":"action.create",
"params":[{
"name":"ZABBIX ACTION",
...
"conditions":[...],
"operations":[{
...
"opmediatypes":[{
"mediatypeid":"100100000000001"
}]
}, ...]
}],
"auth":"038e1d7b1735c6a5436ee9eae095879e",
"id":2
}
After hacking a bit around the code of the frontend, I realized that the correct way to create an action like I wanted was:
Code:
{
"jsonrpc":"2.0",
"method":"action.create",
"params":[{
"name":"ZABBIX ACTION",
...
"conditions":[...],
"operations":[{
...
"mediatypeid":"100100000000001"
}, ...]
}],
"auth":"038e1d7b1735c6a5436ee9eae095879e",
"id":2
}
However, I warn you that if you use action.get to retrieve the action you've just created, you will receive an object like this:
Code:
{
"jsonrpc":"2.0",
"result":[{
"name":"ZABBIX ACTION",
...
"conditions":[...],
"operations":[{
"operationid":"189",
...
"opmediatypes":[{
"opmediatypeid":"12",
"operationid":"189",
"mediatypeid":"100100000000001"
}]
}, ...]
}],
"id":2
}
I share this recipe with you because it's a bit obscure. Maybe it could be thought it's a bug, isn't it?
Comment