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-06-17 18:02:18

aziz
Member
Registered: 2021-03-30
Posts: 109

add solution for a ticket

Hi everyone how can i post solution for a ticket  using api because this request not working https://serveurglpi/apirest.php/ticketsolution/?session-token=xxxxxxxxxxxxxxxxxxx
ty  smile

Offline

#2 2021-06-17 22:33:55

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

Re: add solution for a ticket

Hi,
glpi version ?

try using POST METHOD  with this URL :

    $url=$api_url ."/ITILSolution/";

and this payload :

$payload='{
     "input": {
         "items_id": "'.$ticket_id.'",
         "content": "this is my solution",
         "solutiontypes_id": 2,
         "itemtype": "Ticket",
       
     }
}';
//print_r($fields);
    $ch = curl_init();
    $url=$api_url ."/ITILSolution/";


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-12-30 04:11:07

questioning
Member
Registered: 2021-12-30
Posts: 1

Re: add solution for a ticket

Hi!

Any idea why is not working with version 9.5.5?

I'm able to add solution manually, but using REST API is not working. When solution is added manually I can close ticket with API without any problems.


EDIT:

{ "input": {"items_id": "TICKET_ID" ,"content": "SOLUTION" ,"solutiontypes_id": "2" ,"itemtype": "Ticket"}}

My payload looks like above and I use the same method to load it as in the changing status operation, which basically works.

Strange thing is that response I receive looks completely the same as I tried to run 'ItitlSolution' request with no payload. No exception appears even when I did a mess with my payload structure.

I was wondering if maybe read-only session is the cause, but set up 'get_full_session=True' and 'session_write=1' also did not worked.

Last edited by questioning (2022-01-04 11:11:07)

Offline

#4 2022-06-27 04:50:29

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

Re: add solution for a ticket

Hi!
I tried to post this but got an error return "ERROR_BAD_ARRAY"
Any idea why I got the error?


LaDenrée wrote:

try using POST METHOD  with this URL :

    $url=$api_url ."/ITILSolution/";

and this payload :

$payload='{
     "input": {
         "items_id": "'.$ticket_id.'",
         "content": "this is my solution",
         "solutiontypes_id": 2,
         "itemtype": "Ticket",
     }
}';

Offline

#5 2022-06-27 16:37:42

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

Re: add solution for a ticket

I'm pretty sure most JSON decoders don't like trailing commas.
Does it work if you remove the comma at the end of the "itemtype" line?


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

#6 2022-06-28 04:19:59

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

Re: add solution for a ticket

Nope, same error

i try it using postman with
method: POST
URL: http://xxxx/apirest.php/ITILSolution/
auth: basic auth with glpi username and password
body:
{
    "input":{
        "itemtype": "Ticket",
        "items_id": "59939",
        "content":"MySolutionDescription",
        "status" : 2
    }
}

I've tried to remove the quotation mark on the items_id value but still didn't work

Offline

#7 2023-09-18 14:31:27

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

Re: add solution for a ticket

{
     "input": {
         "items_id": 3,
         "content": "this is my solution",
         "users_id": 12,
         "solutiontypes_id": 2,
         "itemtype": "Ticket",
     }


where 3 is your ticket id, and current user is 12.

use this to send als POST to ITILSolution.

Last edited by akpwijnen (2023-09-18 14:32:21)

Offline

Board footer

Powered by FluxBB