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 2022-11-11 18:16:24

AndiMb
Member
Registered: 2022-11-11
Posts: 12

Add entity by restapi with different name and completename

Hi,

is there a way to add an entity by REST API with different name and completename?

When adding an entity by

curl -X POST \
-H 'Content-Type: application/json' \
-H "Session-Token: $$$" \
-H "App-Token: $$$" \
-d '{"input": {"name": "topentity > subentity"}}' \
--insecure \
'https://server/apirest.php/Entity/'

the name is used as completename and name. Changing to '{"input": {"name": "subentity", "completename": "topentity > subentity"}} doesn't change the result.

Regards

Offline

#2 2022-11-11 22:06:33

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

Re: Add entity by restapi with different name and completename

Completename is not a field you can set (or at least it shouldn't allow you to) it is calculated based on the name and the names of the parent entities. You would need to specify that "topentity" is the parent entity by setting the new entity's "entities_id" field to the ID of "topentity".


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 2022-11-13 20:21:22

AndiMb
Member
Registered: 2022-11-11
Posts: 12

Re: Add entity by restapi with different name and completename

Hi,

thanks for the reply.

I gave it a try but I'm doing something wrong. When trying to add the entity with the following command

curl -X POST \
-H 'Content-Type: application/json' \
-H "Session-Token: $$$" \
-H "App-Token: $$$" \
-d '{"input": {"name": "subentity", "entities_id": "1"}}' \
--insecure \
'https://server/apirest.php/Entity/'

where "1" is the ID of the top entity, I'm getting the following error: "ERROR_GLPI_ADD","You don't have permission to perform this action."

But I'm using Super-Admin account. Do you have an additional hint?

Regards,
Andreas

Offline

#4 2022-11-14 09:23:08

AndiMb
Member
Registered: 2022-11-11
Posts: 12

Re: Add entity by restapi with different name and completename

Hi,

I found the solution for my problem. Before adding a new entity with just the name, I have to set the top entity as the active entity with apirest.php/changeActiveEntities/

Everything works fine now.

Regards,
Andreas

Offline

Board footer

Powered by FluxBB