You are not logged in.
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
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
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
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