You are not logged in.
Pages: 1
Hi guys,
is it possible to access FusionInventory fields in computer via REST API? I cant find info anywhere.
To precise I need info about agent. So I would like to access this field directly.
sth like
/api/computer/123/FusionInventoryAgentID
to return: computer-2018-20-02-10-20
Offline
try this :
…...API/search/PluginFusioninventoryAgent?criteria[0][field]=6&criteria[0][searchtype]=contains&criteria[0][value]=$myComputerId
Trouver la panne avant de réparer...
GLPI10.0.10 (ubuntu 22.04 PHP8.1 Mariadb10.6 ) plugins : comportements 2.7.2 reports 1.16.0 formcreator 2.13.8, datainjection 2.13.4 fields 1.21.6
Offline
Thanks for the reply, althought its not useful for me. The problem is on the server I dont have info about computers' ids in Glpi database. I just have agent id (such as computer-2018-20-02-10-20) which cannot be included in search AFAIK.
Offline
and with thi url ?
$url=$api_url . "/search/PluginFusioninventoryAgent?criteria[0][field]=1&criteria[0][searchtype]=contains&criteria[0][value]=computername-2015-05-20-08-14-04";
Trouver la panne avant de réparer...
GLPI10.0.10 (ubuntu 22.04 PHP8.1 Mariadb10.6 ) plugins : comportements 2.7.2 reports 1.16.0 formcreator 2.13.8, datainjection 2.13.4 fields 1.21.6
Offline
Thanks man! It worked
Please take a look at the output:
'data': [{'1': 'hostname-2015-03-21-00-25-04', '2': 'entity', '4': '2018-11-09 02:53:04', '5': 0, '6': 'hostname-2015-03-21-00-25-04', '7': 'hostname', '8': '{"INVENTORY":"v2.4.1-dev"}', '9': 12345678}]
Do you have an idea how to access directly "hostname" object? I can't use searching based on hostname becouse of duplicates. I need the object linked with this specific agent.
Offline
I'm not sure i understand your need.
try this
$url=$api_url . "/search/PluginFusioninventoryAgent?criteria[0][field]=7&criteria[0][searchtype]=contains&criteria[0][value]=hostname";
Trouver la panne avant de réparer...
GLPI10.0.10 (ubuntu 22.04 PHP8.1 Mariadb10.6 ) plugins : comportements 2.7.2 reports 1.16.0 formcreator 2.13.8, datainjection 2.13.4 fields 1.21.6
Offline
This one also returned 'data': [{'1': 'hostname-2015-03-21-00-25-04', '2': 'entity', '4': '2018-11-09 02:53:04', '5': 0, '6': 'hostname-2015-03-21-00-25-04', '7': 'hostname', '8': '{"INVENTORY":"v2.4.1-dev"}', '9': 12345678}].
Explanation
Let's say I have a server named "hostname". In Glpi it is linked with FusionInv agent (say hostname-2015-03-21-00-25-04).
Now lets say I want to set serial number for this server, but I all can use is FusionInv agent (hostname-2015-03-21-00-25-04). I do not know ID of server linked with it, or anything else.
So now using your solution, I can search for hostname-2015-03-21-00-25-04. In return I got [{'1': 'hostname-2015-03-21-00-25-04', '2': 'entity', '4': '2018-11-09 02:53:04', '5': 0, '6': 'hostname-2015-03-21-00-25-04', '7': 'hostname', '8': '{"INVENTORY":"v2.4.1-dev"}', '9': 12345678}].
"7" is a hostname of server connected with this agent. In Glpi gui I can click on it and see details of "hostname" object.
How to set serial number this way using API? I could search for returned "hostname", but what if i have 3 servers with same hostname? That's why I need to access exact "server object" in Glpi linked with FusInv agent.
Offline
i think i got it but it needs some class modification :
i add a seach option in plugins/fusioninventory/inc/agent.class.php function : rowSearchOptions()
$tab[] = [
'id' => '15',
'table' => $this->getTable(),
'field' => 'id',
'name' =>__('ID'),
'datatype' => 'integer',
];
then i search agent by name forcing display of id (index 15) :
$url=$api_url . "/search/PluginFusioninventoryAgent?criteria[0][field]=1&criteria[0][searchtype]=contains&criteria[0][value]=computername-2015-05-20-08-14-04&forcedisplay[0]=15";
then you get agent id =>$agentid
and get aget : $url=$api_url . "/PluginFusioninventoryAgent/$agentid";
Trouver la panne avant de réparer...
GLPI10.0.10 (ubuntu 22.04 PHP8.1 Mariadb10.6 ) plugins : comportements 2.7.2 reports 1.16.0 formcreator 2.13.8, datainjection 2.13.4 fields 1.21.6
Offline
That's it! Thank you very much
Offline
this will be lost on plugin upgrade.
I request this new search option in GitHub
https://github.com/fusioninventory/fusi … ssues/2713
Trouver la panne avant de réparer...
GLPI10.0.10 (ubuntu 22.04 PHP8.1 Mariadb10.6 ) plugins : comportements 2.7.2 reports 1.16.0 formcreator 2.13.8, datainjection 2.13.4 fields 1.21.6
Offline
Pages: 1