[ZBX-21169] I can't create an action via zabbix api in version 6.0.4 Created: 2022 Jun 04  Updated: 2022 Jun 06  Resolved: 2022 Jun 06

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: None
Affects Version/s: 6.0.4
Fix Version/s: None

Type: Problem report Priority: Trivial
Reporter: Ricardo Barbosa Dias Assignee: Vladimir Stepanov (Inactive)
Resolution: Won't fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Zabbix version: 6.0.4
Ubuntu 20.04.4 LTS
Kernel 5.13.0-1025-aws


Attachments: PNG File Screenshot from 2022-06-04 09-51-38.png     File default.sh    

 Description   

Steps to reproduce:

  1. I use the follow script to create an action.

 

 

#!/usr/bin/env bash

URL='http://192.168.11.95/zabbix/api_jsonrpc.php'
HEADER='Content-Type:application/json'
USER='"Admin"'
PASS='"zabbix"'
authentication()
{
    JSON='
    {
        "jsonrpc": "2.0",
        "method": "user.login",
        "params": {
            "user": '$USER',
            "password": '$PASS'
        },
        "id": 0
    }
    '
    curl -s -X POST -H "$HEADER" -d "$JSON" "$URL" | cut -d '"' -f8
}
TOKEN=$(authentication)
 
createAction()
{
        JSON='
    {
        "jsonrpc": "2.0",     
        "method": "action.create",     
        "params": 
        {
        "name": "Information", 
        "eventsource": 0, 
        "status": 0, 
        "esc_period": "2m", 
        "filter": {
            "evaltype": 0, 
            "conditions": [
            {
                "conditiontype": 4, 
                "operator": 0, 
                "value": 1
            }
            ]
        }, 
        "operations": [
        {
            "operationtype": 0, 
            "esc_period": "1m", 
            "esc_step_from": 1, 
            "esc_step_to": 1, 
            "evaltype": 0, 
            "opmessage_usr": [
            {
                "userid": "2"
            }
            ], 
            "opmessage": {
                "default_msg": 1, 
                "mediatypeid": "9",
                "message": "OI",
                "subject": "test"
            }, 
            "opconditions": [
            {
                "conditiontype": 14,
                "operator": 0, 
                "value": "0"
            }
            ]
        }
        ]
        },     
           "auth": "'$TOKEN'",
               "id": 1
           }
         '
    curl -s -X POST -H "$HEADER" -d "$JSON" "$URL"
}

createAticion
 

 

But it's not work. The follow message is exhibit.

 

 

$ bash default.sh 
{"jsonrpc":"2.0","error":

{"code":-32602,"message":"Invalid params.","data":"Invalid parameter \"/1/operations/1/opmessage\": unexpected parameter \"subject\"."}

,"id":1}
${code}
I tested on 5.0.10 is worked. If i remove the subject and message. It's works on 6.0.4 version.

Let me know if i'm something doing wrong.

Result:
Expected:



 Comments   
Comment by tsuno teppei [ 2022 Jun 06 ]

Since version 6.0, opmessage_user / opmessage_grp / mediatypeid in opmessage is an error for String.
You can solve this problem by making it an Intger.
But this behavior is probably a bug in the Action API.

Comment by Vladimir Stepanov (Inactive) [ 2022 Jun 06 ]

Hi,
The property default_msg for action operation has two values:
Possible values:
0 - use the data from the operation;
1 - (default) use the data from the media type.

If you like to use your custom subject, so you have to set default_msg=0
Please, find more information here;
https://www.zabbix.com/documentation/current/en/manual/api/reference/action/object#action-operation-message

Generated at Sun May 31 19:37:58 EEST 2026 using Jira 10.3.18#10030018-sha1:5642e4ad348b6c2a83ebdba689d04763a2393cab.