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-03-30 05:22:16

KongNan
Member
Registered: 2018-09-01
Posts: 27

[Solved] How to use RestAPI to specify the ticket's requester?

When we use RestAPI to create a ticket, its Requester is set as the owner of apiToken by default.

We wanted to set it to a work ID, but we didn't find out how to do so with API.

How to use RestAPI to specify the ticket's requester?

(Sorry for my English)

Last edited by KongNan (2021-04-06 08:48:13)

Offline

#2 2021-03-30 08:29:21

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

Re: [Solved] How to use RestAPI to specify the ticket's requester?

Hi, when you create your ticket add these paraméters in your JSON

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

edit : moved to API section


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

#3 2021-03-30 09:38:43

Jean-Christophe
Moderator
Registered: 2007-08-22
Posts: 734

Re: [Solved] How to use RestAPI to specify the ticket's requester?

I agree with LaDenrée.

The leading "_" is tricky, I have to say :-)

Offline

#4 2021-03-30 09:58:33

KongNan
Member
Registered: 2018-09-01
Posts: 27

Re: [Solved] How to use RestAPI to specify the ticket's requester?

Thank you, it works!

Can I set the status to "new" instead of "Processing (assigned)"?   I tried to set  '_users_id_assign' to 0 or "" , but it still assigned neutral

Offline

#5 2021-03-30 10:12:03

KongNan
Member
Registered: 2018-09-01
Posts: 27

Re: [Solved] How to use RestAPI to specify the ticket's requester?

Offline

#6 2021-03-31 03:20:14

KongNan
Member
Registered: 2018-09-01
Posts: 27

Re: [Solved] How to use RestAPI to specify the ticket's requester?


Yes, it helps:

My Settings (preference) -> Personalization -> Assistance->

Pre-select me as Technician when Creating Ticket : NO
Pre-select me as Requester when Creating Ticket: NO

Offline

#7 2021-03-31 08:34:43

KongNan
Member
Registered: 2018-09-01
Posts: 27

Re: [Solved] How to use RestAPI to specify the ticket's requester?

LaDenrée wrote:

{
   '_users_id_requester': 2,
}

Thank you for your reply!

I have another question, this _users_id_requester uses the internal ID, but I want to use the "Login" field of the user:  ( for example  333 , auto-collected from windows %username% ).

How to do that?  ( how to get user_id 2 with Login 333 )?

Sorry for my poor English sad

Offline

#8 2021-03-31 08:45:48

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

Re: [Solved] How to use RestAPI to specify the ticket's requester?

first get GLPI's user id :



$url=$api_url . "/search/User?forcedisplay[0]=2&forcedisplay[1]=1&criteria[1][field]=1&criteria[1][searchtype]=contains&criteria[1][value]=" . $login;

in your case $login would be ^333$   that means is exactly 333   otherwise 1333,2333,3333,4333, 3331  would match


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

#9 2021-03-31 09:23:45

KongNan
Member
Registered: 2018-09-01
Posts: 27

Re: [Solved] How to use RestAPI to specify the ticket's requester?

Thank you! let's try that smile

Offline

#10 2021-04-06 08:47:47

KongNan
Member
Registered: 2018-09-01
Posts: 27

Re: [Solved] How to use RestAPI to specify the ticket's requester?

Done! now we can use that to create correct tickets. Thank you!

Offline

Board footer

Powered by FluxBB