Glpi: API : Add / Update subitems

Created on 8 Dec 2016  路  4Comments  路  Source: glpi-project/glpi

Hello,

I need some help. It seem that it's not possible to add / update subitems in GLPI API (version 9.1.1). I try for exemple to add Infocom on a computer and it seems that not working . For exemple :

CURLOPT_URL => 'myapi/Computer/100/Infocom',
CURLOPT_RETURNTRANSFER  => true,
CURLOPT_SSL_VERIFYPEER  => false,
CURLOPT_HTTPHEADER  => array(
   'Content-Type: application/json',
   'App-Token: '.API_TOKEN,
   'Session-Token: '.$this->session,
),
CURLOPT_POSTFIELDS => "{"input" : {"buy_date" : "2016-12-08"}}".

The return is :

array(2) {
  [0]=> string(19) "ERROR_RIGHT_MISSING"
}

I use "glpi" user in Super-Admin group

Thanks for your help

question

All 4 comments

Same behaviour with NetworkPort. It could be really userfull to have the possiblity to add subitem in one shot !

Tanks for your help

Yup, I came across the same problem just today.
I use the API via a python script, however, and what I get as a result of the PUT submission is an empty list.

It's because Infocom have its own ID, you can catch it in response from
apirest.php/Computer/Computer_ID/?with_infocoms=true
InfocomID=json['_infocoms']['id']

and now you can PUT request for InfocomID
apirest.php/Infocom/InfocomID

the same way using for other type of subitems, Network ports etc.

Hi,

I close this issue as a responses has been done.
If you need more help, please use forum.

Regards

Was this page helpful?
0 / 5 - 0 ratings

Related issues

menvol3 picture menvol3  路  7Comments

mab18 picture mab18  路  5Comments

gfernandez-me picture gfernandez-me  路  5Comments

jfg picture jfg  路  6Comments

btry picture btry  路  3Comments