After a GLPI upgrade from version 9.2 to 10.0, the REST API does not seem to return the domain associated to the computers anymore.
Extract of an API call with GLPI REST API 9.2 :
> curl https://<url>/apirest.php/Computer/
{
"id": 9675,
(...)
"name": "MY-COMPUTER",
(...)
"domains_id": 8,
(...)
"links": [
(...)
{
"rel": "Domain",
"href": "https://glpi.antidot.net/apirest.php/Domain/8"
},
(...)
]
}
Extract of an API call with GLPI REST API 10.0 :
> curl https://<url>/apirest.php/Computer/
{
"id": 9675,
(...)
"name": "MY-COMPUTER",
(...)
"links": [
(...) <<<< no 'rel': 'Domain' entry
]
}
I am aware that the "domain" field that was shown in the computer tab is now available under the domain tab, due to a change in database structure (there was a N-1 relationship between computers and domains, and it's now a N-N relationship).
I've checked that the domains are still associated with computers after the migration.
Is there a way to get the domains associated to a computer with GLPI REST API ?
CodePudding user response:
Answer to my own question : The solution is to fetch the Domain_Item
endpoint :
> curl https://<url>/apirest.php/Domain_Item/
(...)
{'id': 1,
'domains_id': 8,
'items_id': 8316,
'itemtype': 'Computer',
'domainrelations_id': 0,
'links': [
{'rel': 'Domain', 'href': 'https://url/apirest.php/Domain/8'},
{'rel': 'Computer', 'href':'https://url/apirest.php/Computer/8316'}
]},
(...)
(it may be a good idea to filter on 'itemtype':'Computer'
too)