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-11-08 23:18:17

aziz
Member
Registered: 2021-03-30
Posts: 109

Set ticket actors while creating a ticket

Hello,
when creating a ticket using API I want to set the actors  (Requester, Assigned To) so how should the payload look like to achieve this.
Ty in advance.

Offline

#2 2021-11-09 15:52:42

mecmav
Member
From: Brasil
Registered: 2019-03-22
Posts: 326

Re: Set ticket actors while creating a ticket

aziz wrote:

Hello,
when creating a ticket using API I want to set the actors  (Requester, Assigned To) so how should the payload look like to achieve this.
Ty in advance.


you need use this:

method POST.

/apirest.php/Ticket/ticket_id/Ticket_User/

and your raw input data looks like this:

{
    "input": {
        "tickets_id": 1,
        "users_id": 2,
        "type": 2
    }
}

type:
1: requester
2: assigned
3: observer

Offline

#3 2021-11-09 16:01:15

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

Re: Set ticket actors while creating a ticket

if you want to create tickets and associate actors in one step use this :

{
   'name': 'title',
   'content': 'content',
   '_users_id_assign': 2,
   '_users_id_requester': 2,
   '_groups_id_assign': 1,
   ...
}

see here : https://forum.glpi-project.org/viewtopic.php?id=280849


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-11-09 17:51:53

aziz
Member
Registered: 2021-03-30
Posts: 109

Re: Set ticket actors while creating a ticket

Thank you LaDenrée for your help but do you have an idea how to set a watcher I tried "_users_id_watcher":  but it didn't work .

Last edited by aziz (2021-11-09 17:52:09)

Offline

#5 2021-11-09 18:41:01

mecmav
Member
From: Brasil
Registered: 2019-03-22
Posts: 326

Re: Set ticket actors while creating a ticket

aziz wrote:

Thank you LaDenrée for your help but do you have an idea how to set a watcher I tried "_users_id_watcher":  but it didn't work .

I will try again ....


you need use this:

method POST.

/apirest.php/Ticket/ticket_id/Ticket_User/

and your raw input data looks like this:

{
    "input": {
        "tickets_id": 1,
        "users_id": 2,
        "type": 2
    }
}

type:
1: requester
2: assigned
3: observer

Offline

#6 2021-11-09 21:49:17

aziz
Member
Registered: 2021-03-30
Posts: 109

Re: Set ticket actors while creating a ticket

I saw your reply too mecmav but I was trying to do this in one request TY anyway smile

Last edited by aziz (2021-11-09 21:49:43)

Offline

#7 2021-11-09 22:50:39

mecmav
Member
From: Brasil
Registered: 2019-03-22
Posts: 326

Re: Set ticket actors while creating a ticket

aziz wrote:

I saw your reply too mecmav but I was trying to do this in one request TY anyway smile

did you manage to do it the way LaDenree said?

Offline

#8 2021-11-10 02:00:48

aziz
Member
Registered: 2021-03-30
Posts: 109

Re: Set ticket actors while creating a ticket

yes that's why I want to know how to do the same thing to set a watcher

Last edited by aziz (2021-11-10 02:01:06)

Offline

#9 2021-11-10 14:29:21

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

Re: Set ticket actors while creating a ticket

this should work :

{"input" :{
   "name": "title",
   "content": "content",
   "_users_id_assign": 4880,
   "_users_id_requester": 4880,
   "_users_id_observer": 4880
    }
}';


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

#10 2023-12-26 15:17:13

gavilareal
Member
From: Brazil
Registered: 2016-10-14
Posts: 4

Re: Set ticket actors while creating a ticket

Hello.

It would be possible to add an observer as an email without a user, using the Rest API?
I have tried different payload to achieve it, like _users_alternative_email, alternative_email, but no success yet

I notice that in table glpi_tickets_users the registers with email as observer have the field userid = 0

I'm using GLPI 10.0.10.


Updated:

I have found a way to update the ticket and set an email as a ticket observer, without a existing user_id needed:

apirest.php/Ticket/ticket_id/Ticket_User/

{
    "input": {
                "id": $id_tickets_users_table,
                "tickets_id": $ticket_id,
                "users_id": "0",
                "type": "2",
                "use_notification": "1",
                "alternative_email":"myobseveremail@mail.mail"
             }
}

Last edited by gavilareal (2024-01-03 00:00:37)

Offline

Board footer

Powered by FluxBB