Methods > glpi.createObjects

Version Comments
1.3.0 no change
1.2.0 must be super admin to use this method
1.1.0 Method added

This method is only accessible by authenticated and super-admin users

Create new objects.

input hashtable

  • help option to get usage information OPTIONAL
    • if you provide an array in this option : the method return all possible fields for each itemtype you put into help array.
  • fields option inject datas into glpi (must be an ARRAY) : if you provide the help option, this option is OPTIONAL

return a hastable

PHP Soap Example script : see GlpicreateObjects_SOAPhp
PHP Xml-Rpc Example script : see GlpicreateObjects_XMLRPCPhp

Help call example

NOTE : it's not possible to use *array* in PHP-CLI call, the following command is just for example.

$ php testxmlrpc.php --session=0ptega61kobcnhkv0vokbercv1 --method=glpi.createObjects --help=array('Computer')
+ Calling 'glpi.createObjects' on http://localhost/glpi/plugins/webservices/xmlrpc.php?session=0ptega61kobcnhkv0vokbercv1
+ Response: Array (
    [Computer] => Array
        (
            [0] => entities_id
            [1] => name
            [2] => serial
            [3] => otherserial
            [4] => contact
            [5] => contact_num
            [6] => users_id_tech
            [7] => comment
            [8] => date_mod
            [9] => operatingsystems_id
            [10] => operatingsystemversions_id
            [11] => operatingsystemservicepacks_id
            [12] => os_license_number
            [13] => os_licenseid
            [14] => autoupdatesystems_id
            [15] => locations_id
            [16] => domains_id
            [17] => networks_id
            [18] => computermodels_id
            [19] => computertypes_id
            [20] => is_template
            [21] => template_name
            [22] => manufacturers_id
            [23] => is_deleted
            [24] => notepad
            [25] => is_ocs_import
            [26] => users_id
            [27] => groups_id
            [28] => states_id
            [29] => ticket_tco
        )
)

Option FIELDS Example

['fields'] = array(
   'DeviceHardDrive'=>array(   
                        array('designation'=>'TEST Disque 1',
                              'comment'=>'Quel beau commentaire!')
                  ),
   'Computer'=>array(   
                        array('name'=>'TEST Ordinateur 1',
                              'serial'=>'I98GFD-FF98-F0ZFDF8-980',
                              'otherserial'=>'0000134',
                              'states_id'=>'1',
                              'users_id'=>'2'),
                        array('name'=>'TEST Ordinateur 2',
                              'serial'=>'FF98-F0ZFDF8-980',
                              'otherserial'=>'000943')
                  )
);

This example inject :
  • one DeviceHardDrive with "TEST Disque 1" in Designation field and "Quel beau commentaire!" in Comment field.
  • two Computer with options passed in those respective arrays.