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 2023-09-07 14:10:06

akpwijnen
Member
Registered: 2023-09-07
Posts: 4

Add Task to ticket through API

When I send the following JSON to the API endpoint: Ticket/24/ITILSolution, where 24 is the ticketnumber
I only get a blank return string (no errors). Unfortunately it doesn't save the task to the ticket.


{"input": {"task": {"name": "New task", "groups_id_tech": 0, "description": "test", "begin_date": "2023-09-07 14:08:58", "due_date": "2023-09-07 14:08:58", "taskcategories_id": 0, "users_id_tech": 11, "itemtype": "Ticket", "items_id": 24}}}

Where:

items_id: 24 is the ticketnumber to add the task to


Please help

Offline

#2 2023-09-07 17:15:53

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

Re: Add Task to ticket through API

Your URL and input isn't valid. The URL you gave is for solutions rather than tasks. The input isn't valid for tasks either. The properties should be nested in a "task" property, but directly in the "input" property instead and the property names don't match what is valid for a task.

Correct info should be:
URL: Ticket/24/TicketTask
Payload: {"input": {"name": "New task", "groups_id_tech": 0, "description": "test", "begin": "2023-09-07 14:08:58", "end": "2023-09-07 14:08:58", "taskcategories_id": 0, "users_id_tech": 11, "tickets_id": 24}}


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 2023-09-07 21:48:31

akpwijnen
Member
Registered: 2023-09-07
Posts: 4

Re: Add Task to ticket through API

Thanks for responding.
Unfortunately I'm now getting 400 error.

url changed to Ticket/24/TicketTask
json: {"input": {"name": "New task", "groups_id_tech": 0, "description": "test new task", "begin": "2023-09-07 21:47:05", "end": "2023-09-08 21:47:05", "taskcategories_id": 0, "users_id_tech": 13, "tickets": 24}}

user 13, and 11 are valid users.

Last edited by akpwijnen (2023-09-07 21:57:34)

Offline

#4 2023-09-09 00:46:48

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

Re: Add Task to ticket through API

I made a typo too:
"tickets" -> "tickets_id"


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

#5 2023-09-09 16:08:01

akpwijnen
Member
Registered: 2023-09-07
Posts: 4

Re: Add Task to ticket through API

I don't know what's wrong but still getting the 400 error:

{"input": {"name": "new task", "groups_id_tech": 0, "description": "test", "begin": "2023-09-09 15:46:17", "end": "2023-09-10 15:46:17", "taskcategories_id": 0, "users_id_tech": 13, "tickets_id": 24}}

Is there a way to get a more informative error message, so I can see what's wrong?

Last edited by akpwijnen (2023-09-09 16:10:51)

Offline

#6 2023-09-09 20:41:30

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

Re: Add Task to ticket through API

Only if the API call is failing from a PHP or SQL error. Then, it should be logged in the log files in the files/_log folder.


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

Board footer

Powered by FluxBB