Ad Widget

Collapse

zabbix 4.4 api host.update tags error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pysany
    Junior Member
    • Jan 2020
    • 1

    #1

    zabbix 4.4 api host.update tags error

    Hi,

    When you attempt to add a tag using host.update as an API, the following error occurs.

    Error:
    {'error': {'data': 'Invalid parameter "/tags/1": an array is expected.', 'message': 'Invalid params.', 'code': -32602}, 'jsonrpc': '2.0', 'id': '0'}


    Requested Parameter
    {"params": {"hostid": "10272", "tags": {"value": "test", "tag": "role"}}, "jsonrpc": "2.0", "id": "0", "method": "host.update", "auth": "eb9149e5b05b7fbf41bb753c76698d55"}


    zabbixUrl="http://192.168.0.42/zabbix/api_jsonrpc.php"
    data = {
    "jsonrpc": "2.0",
    "method": "host.update",
    "params": {
    "hostid":hostId,
    #"inventory_mode":0,
    #"inventory":{
    # "location":"Latvia, Riga"
    #} # This code is no problem.
    "tags": {
    "tag": tagName,
    "value": tagValue
    }
    },
    "auth": token,
    "id":"0"
    }

    zabbix version : 4.4

    Please help me
  • Markku
    Senior Member
    Zabbix Certified SpecialistZabbix Certified ProfessionalZabbix Certified Expert
    • Sep 2018
    • 1781

    #2
    Hi, it says "array is expected", and you currently pass a dictionary. Have you tried this (= passing a one-item list of dictionaries):

    Code:
    "tags": [
        {
            "tag": tagName,
            "value": tagValue
        }
    ]

    Comment


    • pysany
      pysany commented
      Editing a comment
      Thank you! Good~
Working...