Ad Widget

Collapse

Fail to create host with multiple templateid via zabbix 2.2 API

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • juliali
    Junior Member
    • Aug 2013
    • 3

    #1

    Fail to create host with multiple templateid via zabbix 2.2 API

    I sent request to create host as follows:

    {
    "params": {
    "templates": [
    {
    "templateid": "10085"
    },
    {
    "templateid": "10086"
    }
    ],
    "host": "46d948d2-ea88-4921-85c6-981bacaf0cf7",
    "interfaces": [
    {
    "ip": "10.117.38.105",
    "useip": 1,
    "dns": "",
    "main": 1,
    "type": 1,
    "port": "10050"
    },
    {
    "ip": "10.117.38.105",
    "useip": 1,
    "dns": "",
    "main": 1,
    "type": 4,
    "port": "12349"
    }
    ],
    "groups": [
    {
    "groupid": "6"
    },
    {
    "groupid": "7"
    }
    ],
    "inventory": {
    "macaddress_a": "00:50:56:B5:52:36"
    }
    },
    "jsonrpc": "2.0",
    "method": "host.create",
    "auth": "3971515aa9aefb5b7047eb13a3dd8303",
    "id": 0
    }

    The response is:
    {"jsonrpc": "2.0", "id": 0, "error": {"message": "Invalid params.", "code": -32602, "data": "Template with item key "agent.hostname" already linked to host."}}

    But when I removed an template id, and make the request as below. The request succeeded, even though the groupid and interfaces are still 2 for each.

    {
    "params": {
    "templates": [
    {
    "templateid": "10085"
    }
    ],
    "host": "46d948d2-ea88-4921-85c6-981bacaf0cf7",
    "interfaces": [
    {
    "ip": "10.117.38.105",
    "useip": 1,
    "dns": "",
    "main": 1,
    "type": 1,
    "port": "10050"
    },
    {
    "ip": "10.117.38.105",
    "useip": 1,
    "dns": "",
    "main": 1,
    "type": 4,
    "port": "12349"
    }
    ],
    "groups": [
    {
    "groupid": "6"
    },
    {
    "groupid": "7"
    }
    ],
    "inventory": {
    "macaddress_a": "00:50:56:B5:52:36"
    }
    },
    "jsonrpc": "2.0",
    "method": "host.create",
    "auth": "3971515aa9aefb5b7047eb13a3dd8303",
    "id": 0
    }

    What's wrong of it? Why cannot I create a host with multiple template ids?
Working...