You are not logged in.
Hello,
how can I get all operating systems located in "Home -> Setup -> Dropdowns -> Operating systems" with a curl api command ?
For example the content of the dropdowns form the "ITIL Category" works with
curl -vv -u glpi:glpi -X GET -H 'Content-Type: application/json' -H "App-Token: <ID>" -H "Session-Token: <ID>" "http://<glpi server>/apirest.php/itilcategory" | jq
But with
curl -vv -u glpi:glpi -X GET -H 'Content-Type: application/json' -H "App-Token: <ID>" -H "Session-Token: <ID>" "http://<glpi server>/apirest.php/operatingsystem" | jq
it is not working.
Best regards
TobRein
Offline
Did you try with "OperatingSystem" exactly? The type in the URL is case-sensitive.
GLPI Collaborator and Plugin Developer.
My non-English comments are automated translations. Sorry for any confusion that causes.
Mes commentaires non anglais sont des traductions automatiques. Désolé pour toute confusion qui cause.
Mis comentarios que no están en inglés son traducciones automáticas. Perdón por cualquier confusión que cause.
Offline
Ouch, with the correct spelling it is working :-)
curl -u glpi:glpi -X GET -H 'Content-Type: application/json' -H "App-Token: " -H "Session-Token: " "http:/// /apirest.php/OperatingSystem" | jq
[
{
"id": 1,
"name": "rhel_92",
"comment": "",
"date_mod": "2024-03-27 15:49:22",
"date_creation": "2024-03-27 15:49:22"
},
{
"id": 2,
"name": "rhel_93",
"comment": "",
"date_mod": "2024-03-27 16:06:23",
"date_creation": "2024-03-27 16:06:23"
}
]
Is there a documenation for the correct spelling of the values ?
Offline
No, at least not in documentation. That is one of the difficulties with the current API which we are addressing with the new API coming in GLPI 11. The types are directly related to the PHP classes. So, in GLPI 10 at least, you can see the file names in the "src" folder which match the name of the class they contain.
For operating systems then, there is a "src/OperatingSystem.php" file with the "OperatingSystem" class.
GLPI Collaborator and Plugin Developer.
My non-English comments are automated translations. Sorry for any confusion that causes.
Mes commentaires non anglais sont des traductions automatiques. Désolé pour toute confusion qui cause.
Mis comentarios que no están en inglés son traducciones automáticas. Perdón por cualquier confusión que cause.
Offline
To retrieve all operating systems from dropdown menus using an API, you would typically need access to an endpoint that provides this information. If such an endpoint exists, you can make a GET request to it to fetch the list of operating systems. The exact method depends on the API you are using.
For example, if you're using a RESTful API, you might make a GET request to an endpoint like `/operating-systems` or `/dropdowns` to fetch the list of operating systems. The response would then contain the data you need.
However, without more context about the specific API you're working with, it's challenging to provide more detailed guidance. If you can provide more information about the API or the service you're using, I can offer more specific advice.
Offline