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-03-09 17:14:39

jish1702
Member
Registered: 2023-03-09
Posts: 3

Approve or Reject Tickets with REST API

Hi Guys,

We need to make ticket validation through REST API and I am checked with /ITILSolution/ and /Ticketvalidation/ options .
I have no idea which one we use and there is no tutorials found for this .


    $ch = curl_init();
    $url=$api_url . "/Ticket/".$ticket_id."/Ticketvalidation/";
    $input='{"input" :{"status":3,"users_id_validate":'.$users_id_approval.',"comment_validation":'.$comment_validation.'} }';

    curl_setopt($ch, CURLOPT_VERBOSE, true);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $input);
    $request_result = curl_exec($ch);
    curl_close ($ch);

can someone help me?

Thanks!

Offline

#2 2023-03-10 00:13:17

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

Re: Approve or Reject Tickets with REST API

Have you tried doing a GET request on that URL first to find the ID of the desired/latest validation in the ticket, and then include the ID property in the POST fields?


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.

Online

#3 2023-03-10 08:10:42

jish1702
Member
Registered: 2023-03-09
Posts: 3

Re: Approve or Reject Tickets with REST API

Thanks for your prompt response.

This is my code. It always return NULL when i use PUT method . I can post new items and query items but not PUT.

     $ch = curl_init();
     $url =$api_url . "/Ticket/".$ticket_id."/ITILSolution/";
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    $input='{"id":17,"input": {"users_id_validate":2,"status":3}}';
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
    curl_setopt($ch, CURLOPT_POSTFIELDS, $input);
    $errno = curl_errno($ch);
  $errmsg = curl_error($ch);
  $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  $json = curl_exec($ch);
  curl_close ($ch);
  $obj = json_decode($json,true);

Last edited by jish1702 (2023-03-15 07:54:43)

Offline

Board footer

Powered by FluxBB