Ad Widget

Collapse

impossible to create host via API

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Meystin
    Junior Member
    • Sep 2016
    • 5

    #1

    impossible to create host via API

    HI,
    I am working on a script in php to create a host group and some hosts.
    When i use my script i have :API error -32500: No permissions to referred object or it does not exist!
    I work with zabbix 3.2.
    When i create an host with an other group, it works.
    Someone have a solution ?


    a part of my code

    try {//créer un groupe (parking) regroupant tous les hotes (gates)
    $api->hostgroupCreate(array('name' => "parking$param_name"));
    $error = FALSE;
    } catch (Exception $e) {
    echo $e->getMessage();
    $error = TRUE;
    }

    try {
    $api->hostCreate(array('host' => "gate$name_host", 'interfaces' => $param_net, 'groups' => array('groupid' => $id_group), 'templates' => array('templateid' => $id_template), 'invertory_mode' => -1));
    $error = FALSE;
    } catch (Exception $e) {
    echo $e->getMessage();
    $error = TRUE;
    }
    Last edited by Meystin; 29-09-2016, 10:42.
  • Meystin
    Junior Member
    • Sep 2016
    • 5

    #2
    closed

    I solved it
    the right code is:

    try {
    $api->hostCreate(array('host' => "gate$name_host", 'interfaces' => $param_net, 'groups' => array(array('groupid' => $id_group)), 'templates' => array('templateid' => $id_template), 'invertory_mode' => -1));
    $error = FALSE;
    } catch (Exception $e) {
    echo $e->getMessage();
    $error = TRUE;
    }

    Comment

    Working...