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 2021-06-18 13:10:46

sistemas.hpux
Member
Registered: 2019-10-11
Posts: 4

[solved]Create new computer registry by API rest

Hi,

How can i create a new computer registry with a computer name xxx using an api rest call? I can get the registry id by the hostname and modify it, everything with api calls, but i need to create a new computer in same way.

Thanks in advance.

Offline

#2 2021-06-18 15:23:27

Jean-Christophe
Moderator
Registered: 2007-08-22
Posts: 734

Re: [solved]Create new computer registry by API rest

Yes, you can.

I don't know what language you use so I don't have a direct answer, but the API documentation is very precise.

Offline

#3 2021-06-18 16:50:34

LaDenrée
HELPER
Registered: 2012-11-19
Posts: 6,163

Re: [solved]Create new computer registry by API rest

use POST method to create objects.

edit :  moved to API Section


Trouver la panne avant de réparer...
GLPI10.0.10 (ubuntu 22.04 PHP8.1  Mariadb10.6 ) plugins : comportements 2.7.2 reports 1.16.0 formcreator 2.13.8, datainjection 2.13.4 fields 1.21.6

Offline

#4 2021-06-21 10:54:36

sistemas.hpux
Member
Registered: 2019-10-11
Posts: 4

Re: [solved]Create new computer registry by API rest

Jean-Christophe wrote:

Yes, you can.

I don't know what language you use so I don't have a direct answer, but the API documentation is very precise.

English. I didn't find it in the doc but i'll try to see it deeper.

Offline

#5 2021-06-21 11:24:51

LaDenrée
HELPER
Registered: 2012-11-19
Posts: 6,163

Re: [solved]Create new computer registry by API rest

using post method , 

endpoint :  myServer/glpi/apirest/Computer/

payload :
{"input" :
    {"is_recursive": 1,
    "entities_id":2,
    "name":"MyName",
    "serial":"MySerial",
    "otherserial":"Myotherserial",
    "contact":"MyContact",
    "contact_num": null,
    "users_id_tech":0,
    "groups_id_tech":26,
    "comment":"MyCommet",
    "locations_id":426,
    "domains_id":64,
    "networks_id":0,
    "computermodels_id":339,
    "computertypes_id":30,
    "is_template":0,
    "manufacturers_id":1955,
    "users_id":4883,
    "groups_id":63,
    "states_id":1,
    }
}


Trouver la panne avant de réparer...
GLPI10.0.10 (ubuntu 22.04 PHP8.1  Mariadb10.6 ) plugins : comportements 2.7.2 reports 1.16.0 formcreator 2.13.8, datainjection 2.13.4 fields 1.21.6

Offline

#6 2021-06-21 12:59:21

sistemas.hpux
Member
Registered: 2019-10-11
Posts: 4

Re: [solved]Create new computer registry by API rest

Thanks a lot!

Offline

#7 2021-06-21 14:42:02

Jean-Christophe
Moderator
Registered: 2007-08-22
Posts: 734

Re: [solved]Create new computer registry by API rest

sistemas.hpux wrote:
Jean-Christophe wrote:

Yes, you can.

I don't know what language you use so I don't have a direct answer, but the API documentation is very precise.

English. I didn't find it in the doc but i'll try to see it deeper.

I meant programming/scripting language big_smile

Offline

#8 2021-06-21 14:54:12

keepcool5283
Member
Registered: 2013-10-10
Posts: 158

Re: [solved]Create new computer registry by API rest

Hello,

API documentation is here : https://server_adress/apirest.php/


Apps Android GLPI Management : https://play.google.com/store/apps/deta … fr.dmn.app
Site Web : http://mdu-tech.fr/
GLPI 9.5.5 sur IIS 10 / PHP 8 / MySQL

Offline

#9 2021-06-21 17:01:10

sistemas.hpux
Member
Registered: 2019-10-11
Posts: 4

Re: [solved]Create new computer registry by API rest

Jean-Christophe wrote:
sistemas.hpux wrote:
Jean-Christophe wrote:

Yes, you can.

I don't know what language you use so I don't have a direct answer, but the API documentation is very precise.

English. I didn't find it in the doc but i'll try to see it deeper.

I meant programming/scripting language big_smile

Jejejeje, sorry. I was using only curl for tests and then uri method in ansible playbook.


keepcool5283 wrote:

Hello,

API documentation is here : https://server_adress/apirest.php/

Yes, i was looking for it in the wrong place...



Thanks you all very much. I was able to create a new computer as i wanted.

Offline

Board footer

Powered by FluxBB