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-05-13 15:07:01

rocksteady
Member
Registered: 2023-07-07
Posts: 9

How do I use template when creating objects?

Hello. I'm creating a new devices using api, how do I define template id in json?

curl 'https://glpi-dev.example.com/apirest.php/pdu' \
--header 'Content-Type: application/json' \
--header 'App-Token: WyqiqNqoEogZ0HjQpbk656cvtC8IoVPZX9JxBhlh' \
--header 'Session-Token: rl3r5nuj1viu3ouv87legpinp4' \
--data '{"input": {"name": "A040-A", "templates_id": 2}}'

Offline

#2 2024-05-13 20:03:04

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

Re: How do I use template when creating objects?

I don't think this is possible. Templates are handled at the web UI display level, so the API doesn't use any of that logic.

Instead, fetch the PDU item that represents the template and copy that data into the request to create a new PDU.
Assuming PDU 2 is the template:
GET https://glpi-dev.example.com/apirest.php/PDU/2


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