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-11-01 20:25:44

roney-cs
Member
Registered: 2019-01-02
Posts: 13

create assigned ticket for a technician with REST API

I'm trying to create a ticket where I need to assign it to the technician, using the REST API

I'm sending something similar to this:


fetch('https://serverglpi.local/apirest.php/ticket', {
                method: 'POST',
                headers: {
                    'Session-Token': result.authToken,
                    'Content-Type': 'application/json'
                },
                body: JSON.stringify(requestBody)
            })


         const requestBody = {
                input: {
                    name: title,
                    content: description,
                    date: currentdatetime,
                    entities_id: entity,
                    technicians_id: loggedInUsername
                }
            };

I tried passing the ID in technicians_id, but the ticket is opened but without the one assigned to it.

I validated the variable loggedInUsername is receiving 12 for example.

Last edited by roney-cs (2024-11-01 20:26:15)

Offline

#2 2024-11-01 21:25:42

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

Re: create assigned ticket for a technician with REST API

Le champ « technicians_id » n'est pas valide pour les billets. Essayez plutôt « _users_id_assign ».


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-11-01 21:50:48

roney-cs
Member
Registered: 2019-01-02
Posts: 13

Re: create assigned ticket for a technician with REST API

Thank you for your interaction on this call.


Verion GLPI 9.3.3

I tested it by passing _users_id_assign and also users_id_assign

it had no effect.


const requestBody = {
                input: {
                    name: title,
                    content: description,
                    date: currentdatetime,
                    entities_id: entity,
                    users_id_assign : loggedInUsername
                }
            };



fetch('https://glpiserver/apirest.php/ticket', {
                method: 'POST',
                headers: {
                    'Session-Token': result.authToken,
                    'Content-Type': 'application/json'
                },
                body: JSON.stringify(requestBody)
            })


The ticket was opened with all the information, but it was not assigned to user 12, for example

Last edited by roney-cs (2024-11-01 22:07:35)

Offline

#4 2024-11-02 13:22:21

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

Re: create assigned ticket for a technician with REST API

Missing an underscore at the beginning. It is "_users_id_assign" not "users_id_assign". It isn't an actual property of the ticket, but instead just a sort of virtual one that tells the ticket code to create a link between the user and the ticket, so it has an underscore at the front.


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