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 2017-06-05 15:57:05

hypemonkey
Member
Registered: 2017-06-05
Posts: 8

Question - Create a ticket through the GLPI's API

Hi, I was looking at the documentation for the API in the version 9+.
I can`t find the procedure to create a ticket manually through the API.

I am not sure if I should use CreateItems(https://fossies.org/dox/glpi-9.1.3/classAPI.html#ac7f13f8b6f29aa2ac95226eecb6f1fd6) or CreateTicket(https://fossies.org/dox/glpi-9.1.3/classTicketRecurrent.html#acd62a67b699bec6f0223c0de9153562b).

More information about what exactly I am trying to do:
We have an homemade .NET app. We want to use the GLPI`s API inside our custom APP to create tickets. At the same time, we would like to fill the ticket's basic information (title, description, watchers, assigned, few more) - nothing too fancy

May someone provide me few hints/advice to do this ?

Thank you big_smile

Note: Github issue link

Last edited by hypemonkey (2017-06-05 15:59:45)

Offline

#2 2017-06-06 14:31:24

hypemonkey
Member
Registered: 2017-06-05
Posts: 8

Re: Question - Create a ticket through the GLPI's API

May I have some help on this? It would be greatly appreciated!

thx

Last edited by hypemonkey (2017-06-06 14:31:38)

Offline

#3 2017-06-06 15:53:08

yllen
GLPI-DEV
From: Sillery (51)
Registered: 2008-01-14
Posts: 15,278

Re: Question - Create a ticket through the GLPI's API

You must use http://localhost/glpi91/apirest.php/#add-items


CentOS 6.5 - CentOS 7.x
PHP 5.6 - PHP 7.x - MySQL 5.6  - MariaDB 10.2 + APC + oOPcache
GLPI from 0.72 to dev version
Certifiée ITIL (ITV2F, ITILF, ITILOSA)

Offline

#4 2017-06-12 19:15:36

hypemonkey
Member
Registered: 2017-06-05
Posts: 8

Re: Question - Create a ticket through the GLPI's API

Hi, thank you for the suggestion. I have a problem, I am stuck on initSession...

here's my code:

Dim wHeader As WebHeaderCollection = New WebHeaderCollection()

wHeader.Clear()

wHeader.Add("Authorization: user_token xxx")
        
wHeader.Add("App-Token: xxx")


Dim sUrl As String = "http://glpi/apirest.php/initSession/"

Dim wRequest As HttpWebRequest = DirectCast(WebRequest.Create(sUrl), HttpWebRequest)

wRequest.ContentType = "application/json"
wRequest.Headers = wHeader
wRequest.Method = "GET"

Dim wResponse As HttpWebResponse = DirectCast(wRequest.GetResponse(), HttpWebResponse)

When I run this code, it stuck on wRequest.GetResponse() and eventually, the request just time out... Any idea ?

Thx !

Last edited by hypemonkey (2017-06-12 19:17:22)

Offline

#5 2017-06-12 20:22:43

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

Re: Question - Create a ticket through the GLPI's API

Hi,
did youy try  :

Dim sUrl As String ="http://glpi/apirest.php/initSession/?Content-Type=%20application/json&app_token=".$app_token ."&user_token=".$user_token"


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

#6 2017-06-12 22:06:42

hypemonkey
Member
Registered: 2017-06-05
Posts: 8

Re: Question - Create a ticket through the GLPI's API

Thank you for the tip! I just tried it in the browser directly. It look like the page don't load (load infinitely). Maybe I am missing a config in GLPI ?

Note: I can see the log in GLPI: 9224588    2017-06-12 16:02            Enpoint 'initSession' called by xx.xx.xx.xx

The server just return nothing...

Really weird

Last edited by hypemonkey (2017-06-12 22:07:34)

Offline

#7 2017-06-12 22:22:22

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

Re: Question - Create a ticket through the GLPI's API

hi,
check :"http://localhost/glpi/apirest.php" you should get api help page.

setup>general>API(tab)
check if api is active,
check if authentication with user token is active

check if your client ip is allowed.


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

#8 2017-06-15 19:11:05

hypemonkey
Member
Registered: 2017-06-05
Posts: 8

Re: Question - Create a ticket through the GLPI's API

I can see I get the session token from the url you said. But, it is really really slow to get a response (10 mins). It just make no sense... Any idea why it is slow like this ?

Thx !

Offline

#9 2017-06-19 15:44:27

hypemonkey
Member
Registered: 2017-06-05
Posts: 8

Re: Question - Create a ticket through the GLPI's API

Hi, I wonder if I may get some help on this... InitSession is extremely slow... Thx !

Offline

Board footer

Powered by FluxBB