Ad Widget

Collapse

Update Action operations from Zabbix API

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jaragunde
    Junior Member
    • Jan 2011
    • 13

    #1

    Update Action operations from Zabbix API

    Hi,

    I'm trying to update the list of action operations for an existing Action object via API. Unfortunately, I get an error when trying to do it, and the error message nor the API documentation have been of much help so far.

    Here are the messages exchanged on the update operation:

    Request:
    Code:
    {
      "id":0,
      "auth":"ffc03bf437cd01dc334125872ea952d3",
      "jsonrpc":"2.0",
      "method":"action.update",
      "params":{
        "actionid":"21",
        "operations":[{
          "operationtype":0,
          "objectid":7,
          "object":1
        }]
      }
    }
    Response:
    Code:
    {
      "jsonrpc":"2.0",
      "error":{
        "code":-32602,
        "message":"Invalid params.",
        "data":"[ CAction::update ] Action [  ] already exists"
      },
      "id":0
    }

    To give some more context, I have Zabbix 1.8.4, and I'm using the Admin user, who has enough permissions (I created the action in the same session). Finally I paste the API operation with which I created that action object:

    Request:
    Code:
    {
      "id":0,
      "auth":"ffc03bf437cd01dc334125872ea952d3",
      "jsonrpc":"2.0",
      "method":"action.create",
      "params":{
        "name":"\\n\\t\\t\\tAlerta 001\\n\\t\\t",
        "eventsource":"0",
        "evaltype":"0",
        "status":"0",
        "esc_period":"0",
        "def_shortdata":"{TRIGGER.NAME}: {TRIGGER.STATUS}",
        "def_longdata":"{TRIGGER.NAME}: {TRIGGER.STATUS}\\r\\nLast value: {ITEM.LASTVALUE}\\r\\n\\r\\n{TRIGGER.URL}",
        "recovery_msg":"0",
        "r_shortdata":"{TRIGGER.NAME}: {TRIGGER.STATUS}",
        "r_longdata":"{TRIGGER.NAME}: {TRIGGER.STATUS}\\r\\nLast value: {ITEM.LASTVALUE}\\r\\n\\r\\n{TRIGGER.URL}",
        "conditions":[{"conditiontype":"2","operator":"0","value":"16041"}],
        "operations":[{"operationtype":0,"objectid":1,"object":0}]
      }
    }
    Response:
    Code:
    {
      "jsonrpc":"2.0",
      "result":{"actionids":["21"]},
      "id":0
    }
    Thank you very much.
  • jaragunde
    Junior Member
    • Jan 2011
    • 13

    #2
    Solution

    I finally managed to figure it out by myself .

    The error message was incorrect, but it had its point: the problem was related with an empty 'name' field, I cannot rename the action with an empty name.

    So the solution was to include the name of the action in the request too, and it worked flawlessly; but I guess this is probably a bug: the duplicated name check is being done although I don't want to change it.

    Code:
    {
      "id":0,
      "auth":"ffc03bf437cd01dc334125872ea952d3",
      "jsonrpc":"2.0",
      "method":"action.update",
      "params":{
        "actionid":"21",
        "name": "my action",
        "operations":[{
          "operationtype":0,
          "objectid":7,
          "object":1
        }]
      }
    }

    Comment

    Working...