Ad Widget

Collapse

Python API Error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • marsbuck
    Junior Member
    • Sep 2012
    • 2

    #1

    Python API Error

    Hey:

    While i using zabbix python api to create host
    i meet errors

    Traceback (most recent call last):
    File "test.py", line 57, in <module>
    zapi.host.create({ 'name':'testname', 'host' : '192.168.1.1','ip' : '192.178.1.2','port' : 10050,'useip' : 0,'groups' : [{ "groupid":gid}],'templates' : [{ "templateid":tid}]})
    File "/home/zhiguo/zabbix/zabbix_api.py", line 346, in method
    return self.universal("%s.%s" % (self.data["prefix"], name), opts[0])
    File "/home/zhiguo/zabbix/zabbix_api.py", line 80, in wrapper
    return self.do_request(self.json_obj(method, opts))['result']
    File "/home/zhiguo/zabbix/zabbix_api.py", line 353, in do_request
    return self.parent.do_request(req)
    File "/home/zhiguo/zabbix/zabbix_api.py", line 307, in do_request
    raise ZabbixAPIException(msg, jobj['error']['code'])
    zabbix_api.ZabbixAPIException: (u'Error -32602: Invalid params., No interfaces for host "192.168.1.1". while sending {"params": {"templates": [{"templateid": "10085"}], "name": "testname", "ip": "192.178.1.2", "useip": 0, "host": "192.168.1.1", "groups": [{"groupid": "6"}], "port": 10050}, "jsonrpc": "2.0", "method": "host.create", "auth": "7894f7d64a3f30e1754dd9d2eeb5a493", "id": 4}', -32602)


    my python code is

    zapi.host.create({ 'name':'testname', 'host' : '192.168.1.1','ip' : '192.178.1.2','port' : 10050,'useip' : 0,'groups' : [{ "groupid":gid}],'templates' : [{ "templateid":tid}]})
    please help me to find my fault

    Thanks
    marsbuck
    Last edited by marsbuck; 04-09-2012, 04:01.
  • marsbuck
    Junior Member
    • Sep 2012
    • 2

    #2
    2.x api have change

    is the proble of zabbix api 2.x have changed
    "interfaces":[
    {
    "type":1,
    "main":1,
    "useip":1,
    "ip":"192.168.3.1",
    "dns":"",
    "port":10050
    }
    it does seem "Invalid params., No interfaces for host" is complaining about a missing "interfaces" parameter,

    Comment

    Working...