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-26 09:15:43

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

How to import Assets into GLPI via API

Hello,

I imported the tickets of our old ticketsystem via API now I wonder if i can do the same thing with the Computers how would that work ?

With kind regards

SomeDude

Offline

#2 2024-03-26 12:39:56

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

Re: How to import Assets into GLPI via API

The process is the same. You need to know the internal class name for the type of asset (Computer, Monitor, NetworkEquipment, etc) and the names of the fields the items of that type can have (you can see this by getting an existing item of that type via the API).

For example, to create a computer:
POST /apirest.php/Computer
Body:
{
    "id": 60,
    "entities_id": 0,
    "name": "ComputerFromAPI",
    "serial": "MySerialNumber"
}

Your other option is the Data Injection plugin which lets you import data with a CSV file instead.
https://plugins.glpi-project.org/#/plugin/datainjection


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-04-04 08:01:17

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

Re: How to import Assets into GLPI via API

Hello,

sorry for the late reply, I tried the API method and I only get the error "ERROR_BAD_ARRAY".

As a test I pulled a Computer I created and tried to post it again to add a new one after changing id, name and serialnumber.


Any ideas what im doing wrong, I am using Postman.

Offline

#4 2024-04-04 09:19:50

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

Re: How to import Assets into GLPI via API

Found my mistake forgot to add input:

bsp.

{"input":
{
    "id": 4,
    "entities_id": 1,
    "name": "Test API",
    "groups_id_tech": 1,
    "serial": 123543,
    "users_id": 3215
}
}

Offline

#5 2024-04-04 17:23:39

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

Re: How to import Assets into GLPI via API

Sorry, I forgot that was required for the current GLPI API.


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

Board footer

Powered by FluxBB