Ad Widget

Collapse

[API] Host.create problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • toine7m
    Member
    • Feb 2017
    • 93

    #1

    [API] Host.create problem

    Hi,

    I'm using the Zabbix API call to create hostgroup for a project purpose, but I encounter this problem :

    When I create my hostgroup, everything is fine, I got his ID, it's 17 at the moment. When I try to create hosts in this hostgroup, I've got a "
    I'm using the PHPZabbixAPI to call the API via PHP, and I've this problem with Zabbix :

    Array
    (
    [jsonrpc] => 2.0
    [error] => Array
    (
    [code] => -32500
    [message] => Application error.
    [data] => No permissions to referred object or it does not exist!
    )

    [id] => 2
    )
    But, when I create the exact same hosts, with the groupid at something like 2, it's working !!
    The thing is the API doesn't let me create hosts in hostgroup with groupid >10 !

    Here is my code if you want :
    $data = array(
    'jsonrpc' => "2.0",
    'method' => "host.create",
    'params' => array(
    'host' => $hostNameUnique,
    'interfaces' => array('type' => 1, 'main' => 1, 'useip' => 1, 'ip' => '0.0.0.0', 'dns' => '', 'port' => '10050'),
    'groups' => array('groupid' => '17'),
    'name' => $hostName
    ),
    'id' => "2",
    'auth' => $api
    );
    Last edited by toine7m; 26-04-2017, 17:21.
  • toine7m
    Member
    • Feb 2017
    • 93

    #2
    UP, I used the default curl version of API call instead of a library, but the same problem appears, so the problem is in the Zabbix API I think

    Comment

    • toine7m
      Member
      • Feb 2017
      • 93

      #3
      Resolved.

      It's an API problem !

      Workaround is to add brackets [] for each propertiy, like the hostgroup. After that zabbix API allow us to use hostgroup >10 without problems

      I let this here if someone has the same error, without loosing 2 days on it

      Comment

      Working...