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-04-09 12:09:02

SomeDude
Member
Registered: 2023-11-22
Posts: 62

How to add a Operatingsystem through id API

Hello,

I managed to add Computers to GLPI via the API now I had the question if I can add an Operatingsystem while adding the PC`s.
I found some post about sql and found that this link xxx/apirest.php/Computer/1/OperatingSystem outputs the systems but I dont think I am any closer to finding the solution.
Some help please .

Kind regards
SomeDude

Offline

#2 2024-04-10 08:22:06

SomeDude
Member
Registered: 2023-11-22
Posts: 62

Re: How to add a Operatingsystem through id API

Tried this 
{"input":
{
    "name": "TESTTET0",
    "itemtype": "Computer",
    "operatingsystems_id": "1",
    "links": [{
        "rel": "OperatingSystem",
        "href": "pathtoglpi/apirest.php/OperatingsSystem/1"
    }]
   
}
}
also without the links and also with "Operatingsystems_id": "Windows 11" and with "operatingsystems_id": 1

Offline

#3 2024-04-10 12:46:16

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

Re: How to add a Operatingsystem through id API

That is not the correct URL or JSON body to associate a Computer and OS. In GLPI, Operating System is a standalone item with just a name, comment, and creation/modification dates. Item_OperatingSystem is the actual link between assets and OS.

POST /apirest.php/Item_OperatingSystem
Body:
{
    "input": {
        "itemtype": "Computer",
        "items_id": 1,
        "operatingsystems_id": 1
    }
}

There are other fields available in the link:
Selection-296.png


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

#4 2024-04-11 08:07:49

SomeDude
Member
Registered: 2023-11-22
Posts: 62

Re: How to add a Operatingsystem through id API

Thank you very much

Offline

Board footer

Powered by FluxBB