You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2024-03-28 07:43:10

tobrein
Member
Registered: 2024-03-27
Posts: 5

API get all Operating Systems from Dropdowns

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

#2 2024-03-28 11:45:20

cconard96
Moderator
Registered: 2018-07-31
Posts: 2,418
Website

Re: API get all Operating Systems from Dropdowns

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

#3 2024-03-28 12:15:25

tobrein
Member
Registered: 2024-03-27
Posts: 5

Re: API get all Operating Systems from Dropdowns

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

#4 2024-03-28 12:33:11

cconard96
Moderator
Registered: 2018-07-31
Posts: 2,418
Website

Re: API get all Operating Systems from Dropdowns

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

#5 2024-03-29 08:20:13

Shylie
Member
Registered: 2024-03-06
Posts: 3

Re: API get all Operating Systems from Dropdowns

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

Board footer

Powered by FluxBB