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 2022-06-07 05:12:17

ila
Member
Registered: 2022-03-10
Posts: 11

REST API Create Ticket to certain entity

Hi

I have successfully created tickets using API but now I need to create ticket using API only for certain entity (different from the current default entity on the user)
So I need to config the entity for when the ticket will be created
is there any way to do it?

the current code i used for create ticket is:

ticket = dict()
ticket['type'] = ticket_type_id
ticket['itilcategories_id'] = ticket_cat_id
ticket['locations_id'] = ticket_loc_id
ticket['name'] = ' ticket_title_text
ticket['content'] = ticket_desc_text

then I call PUT request using Add_Item API with ticket dict() as the data and item_type =  Ticket


Thanks

Offline

#2 2022-06-08 18:53:28

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

Re: REST API Create Ticket to certain entity

You need to specify the "entities_id" field in the ticket input.


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 2022-06-29 13:51:20

foulla
Member
Registered: 2022-06-07
Posts: 4

Re: REST API Create Ticket to certain entity

Hello everyone,
I am trying to use the Rest API
Actually I am not sure about which parameters I need to send in the request
Please Where can I find an exemple of a POST request for creating a ticket with a description of parameters?

Offline

#4 2022-06-29 13:57:41

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

Re: REST API Create Ticket to certain entity

post moved to API section


Trouver la panne avant de réparer...
GLPI10.0.16 (ubuntu 22.04 PHP8.1  Mariadb10.6 ) plugins : comportements 2.7.3 reports 1.16.0 formcreator 2.13.9, datainjection 2.13.5 fields 1.21.9

Offline

#5 2022-06-30 04:05:34

ila
Member
Registered: 2022-03-10
Posts: 11

Re: REST API Create Ticket to certain entity

cconard96 wrote:

You need to specify the "entities_id" field in the ticket input.

thanks!

Offline

#6 2022-06-30 04:21:43

ila
Member
Registered: 2022-03-10
Posts: 11

Re: REST API Create Ticket to certain entity

foulla wrote:

Please Where can I find an exemple of a POST request for creating a ticket with a description of parameters?

I never find any, but here:

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

the URL is: http://xxx/apirest.php/Ticket/

for the input:

name: ticket title
content: ticket description
itilcategories_id: ticket category id
type: ticket type id
locations_id : location id

you get session token from initsession:
$ curl -X GET \
-H 'Content-Type: application/json' \
-H "Authorization: Basic base64({login}:{password})" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
'http://xxx/apirest.php/initSession'

Last edited by ila (2022-06-30 04:22:12)

Offline

Board footer

Powered by FluxBB