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 2019-10-25 09:49:35

headquaker
Member
Registered: 2015-03-23
Posts: 28

GLPI - Ticket Creation Help

Hello,
I am asking you because I am fed up to search how to do it.
I just want to create a ticket in GLPI using the REST API.
I can initsession but after that, when I am testing a ticket creation, the request seems OK but no ticket is  created.

curl -X POST -H 'Content-Type: application/json' -H "Session-Token: xxxxxxxx" -H "App-Token: yyyyyyyyyy" -d '{"input": {"name": "Ticket Name", "content": "Ticket Desc","status":"1","urgency":"1","_disablenotif":true}}' 'http://glpiserver/apirest.php/itilsolution/'

GLPI : 9.4.4

Another question is : how can I find all the field I can use in the request.
I've read the documentation but nothing is talking about that.

Thank you !

Offline

#2 2019-10-25 10:33:07

headquaker
Member
Registered: 2015-03-23
Posts: 28

Re: GLPI - Ticket Creation Help

While I found it:
curl -X POST -H 'Content-Type: application/json' -H "Session-Token: xxxxxxxx" -H "App-Token: yyyyyyyyyy" -d '{"input": {"name": "Ticket Name", "content": "Ticket Desc","status":"1","urgency":"1"}}' 'http://glpiserver/apirest.php/Ticket/'

Offline

#3 2019-10-25 10:37:23

headquaker
Member
Registered: 2015-03-23
Posts: 28

Re: GLPI - Ticket Creation Help

Now I am looking for the field to put a requester

Offline

#4 2019-10-25 10:42:54

LaDenrée
HELPER
Registered: 2012-11-19
Posts: 5,364

Re: GLPI - Ticket Creation Help

"_users_id_requester": $users_id.


Trouver la panne avant de réparer...
*GLPI 9.4.6+fusion9.4+2.4+behaviours2.3.2+reports+fields+appliances+pdf+badges+formcreator2.10.4 PHP7.4 Mariadb10.3
*GLPI 9.4.6(behaviours2.2.1+fusioninventoty 9.4+1.1+applicatifs2.5.0+fields 1.9.1) php7.3 mysql5.6 hebergé sur serveur mutualisé.
TEST GLPI9.5.4 mutualisé OVH ( sodium error, Marketplace key KO) php 7.3

Offline

#5 2019-10-25 10:57:07

headquaker
Member
Registered: 2015-03-23
Posts: 28

Re: GLPI - Ticket Creation Help

Yes I find it thanks but can I change the $users_id ?

Offline

#6 2019-10-25 11:59:41

headquaker
Member
Registered: 2015-03-23
Posts: 28

Re: GLPI - Ticket Creation Help

Is it possible to use a ticket template for creation?

Offline

#7 2019-10-25 12:59:14

headquaker
Member
Registered: 2015-03-23
Posts: 28

Re: GLPI - Ticket Creation Help

LaDenrée wrote:

"_users_id_requester": $users_id.

I do not know how to use that, it is not working when I try this :

curl -X POST -H 'Content-Type: application/json' -H "Session-Token: xxxxxxxx" -H "App-Token: yyyyyyyyyy" -d '{"input": {"name": "Ticket Name", "content": "Ticket Desc","status":"1","urgency":"1","_users_id_requester":"1"}}' 'http://glpiserver/apirest.php/Ticket/'

Offline

#8 2019-10-25 13:16:39

headquaker
Member
Registered: 2015-03-23
Posts: 28

Re: GLPI - Ticket Creation Help

Arf thats Ok, it was not working because I would like to add a group and not a user -_-

Offline

#9 2019-10-25 15:52:53

headquaker
Member
Registered: 2015-03-23
Posts: 28

Re: GLPI - Ticket Creation Help

How to use variables with space and others things into the curl commande because this is not working ..."name": $1,...

Got the error : ["ERROR_JSON_PAYLOAD_INVALID","JSON payload seems not valid"]

Offline

#10 2019-10-25 16:00:41

headquaker
Member
Registered: 2015-03-23
Posts: 28

Re: GLPI - Ticket Creation Help

I would like to use a variable like this : CH - Hunenberg - Disponibilité WAN (x.x.x.x)

Offline

#11 2019-10-29 10:41:55

headquaker
Member
Registered: 2015-03-23
Posts: 28

Re: GLPI - Ticket Creation Help

Bon voici mon script complet pour aider ceux qui ont du mal

#!/bin/bash
APISESSION=$(curl -s -X GET -H 'Content-Type: application/json' -H "Authorization: user_token: XXXXXXXXX" -H "App-Token: YYYYYYYYY" 'http://SERVER/glpi/apirest.php/initSession' | grep -o -P '(?<=:").*(?=")')

EVENTNAME=$1
TRIGGERSEVERITY=$2

case $2 in
     Disaster)
          PRIORITY=5
          ;;
     Critical)
          PRIORITY=4
          ;;
     High)
          PRIORITY=3
          ;;
esac

curl -H POST \
'http://SERVER/glpi/apirest.php//Ticket/' \
-H 'App-Token: YYYYYYYYY' \
-H 'Content-Type: application/json' \
-H 'Cookie: glpi_token' \
-H 'Host: localhost' \
-H 'Session-Token: '${APISESSION}'' \
-d '{
"input": {
        "name": "'"${EVENTNAME}"' (Zabbix)",
        "content": "'"${EVENTNAME}"' - Severity :'"${TRIGGERSEVERITY}"'",
                        "status":"1",
                        "urgency":"1",
                        "priority":"'"${PRIORITY}"'",
                        "_groups_id_requester":"1"
}
}'

curl -X GET \
-H 'Content-Type: application/json' \
-H 'Session-Token: '${APISESSION}'' \
-H "App-Token: YYYYYYYYY" \
'http://SERVER/glpi/apirest.php/killSession'

Offline

#12 2019-12-08 15:37:15

wtralui
Member
Registered: 2019-12-07
Posts: 25

Re: GLPI - Ticket Creation Help

Hi bro,
Could you contact me in any way?
Have you been able to troubleshoot your script issue? I have the same idea of wanting to create a

Offline

#13 2021-03-21 04:35:24

mkdalmam
Member
Registered: 2021-03-21
Posts: 9

Re: GLPI - Ticket Creation Help

Hello, I am also wanting to do what you reported. You can indicate how you solved it.
I'm waiting.
Thanks

Offline

#14 2021-04-16 17:19:30

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

Re: GLPI - Ticket Creation Help

What you trying to do ?

Offline

#15 2021-04-30 16:18:07

mkdalmam
Member
Registered: 2021-03-21
Posts: 9

Re: GLPI - Ticket Creation Help

Hi mecmav,
I am looking to use the API to create tickets.
TYPE:
I need the API to provide data for creating tickets.
I do not know where to start.
Thanks

Offline

Board footer

Powered by FluxBB