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 2018-10-19 12:14:57

aerozol
Member
Registered: 2018-10-19
Posts: 4

RESTful API usage for ticket update

Hi guys,
I have a problem with structure of object when i want to change it.

  $obj = [
        "input" => [
            "_date" => "04-10-2018 09:44",
            "date" => "2018-10-04 09:44:13",
            "users_id_recipient" => "487",
//            "_time_to_own" => " ",
//            "time_to_own" => " ",
//            "_time_to_resolve" => " ",
//            "time_to_resolve" => " ",
//            "_internal_time_to_own" => " ",
//            "internal_time_to_own" => " ",
//            "_internal_time_to_resolve" => " ",
//            "internal_time_to_resolve" => " ",
            "type" => "1",
            "itilcategories_id" => "0",
            "status" => "1",
            "requesttypes_id" => "1",
            "urgency" => "3",
            "global_validation" => "1",
            "impact" => "3",
            "locations_id" => "5",
            "priority" => "3",
            "my_items" => "",
            "itemtype" => "0",
            "items_id" => "0",
            "_itil_requester" => ["_type" => " 0"],
            "_itil_observer" => [
                "_type" => "user",
                "users_id" => "487",
                "use_notification" => [1],
                "alternative_email" => ["some_mail@gmai.com]
            ],
            "_itil_assign" => ["_type" => " 0"],
            "name" => "NEW TICKET",
            "content" => "<p>NEW TICKET BY REST</p>",
            "_link" =>
                ["link" => " 1",
                    "tickets_id_1" => "110",
                    "tickets_id_2" => "0"
                ],
            "filename" => [" (binary)"],
            "update" => "Save",
            "_read_date_mod" => "2018-10-18 14:43:40",
            "id" => "112"
        ],
        "format" => 'json'
    ];

When i'm trying to update the ticket and assign watchers (_itil_observer) or assigned users (_itil_assign) the request din't change anything. It's work correct in interface but i cant implement it in request.
Can you tell me where is my mistake? Thanks!

Offline

#2 2018-10-22 14:04:02

aerozol
Member
Registered: 2018-10-19
Posts: 4

Re: RESTful API usage for ticket update

I'ts not possible to set observers and assigned users from api  at the moment .
In the api.class.php

 //update item
                        $object = Toolbox::sanitize((array)$object);

returns only one level key=>value object. When you set in dept like

"_itil_observer" => [
                "_type" => "user",
                "users_id" => "487",
                "use_notification" => [1],
                "alternative_email" => ["some_mail@gmai.com]
            ]

the function returns empty string...

Last edited by aerozol (2018-10-22 14:04:48)

Offline

#3 2018-10-22 16:36:03

LaDenrée
HELPER
Registered: 2012-11-19
Posts: 4,658

Re: RESTful API usage for ticket update

if you want to add users to a ticket :

$url=$api_url . "/Ticket/".$ticket_id."/Ticket_User/";
method POST
$input='{ "input": {"tickets_id": '.$ticket_id.' ,"users_id": '.$user_id.',"type": "2","use_notification": "1"}}';

with type :
   // Requester  1;
   // Assign    2;
   // Observer  3;


Trouver la panne avant de réparer...
*GLPI 9.1.6+fusion9.1+1.1+behaviours1.5.0+reports+fields+appliances+pdf+badges+formcreator2.5.2 PHP7.0 Mariadb10
*GLPI 9.4.3(behaviours2.2.1+fusioninventoty 9.4+1.1+applicatifs2.5.0+fields 1.9.1)hebergé sur serveur mutualisé.

Offline

#4 2018-10-30 16:02:28

aerozol
Member
Registered: 2018-10-19
Posts: 4

Re: RESTful API usage for ticket update

Thanks solved

Offline

#5 2019-06-18 17:43:55

ykatir22
Member
Registered: 2019-05-17
Posts: 9

Re: RESTful API usage for ticket update

Hi,
I try to change my GLPI ticket status to closed but i have a servor error, Can anyone help me to solve it

the call URL was : apirest.php/Tikcet/$tickets_id
body :{"input":{"tickets_id":"1906180012","status":"6"}}

the response was :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>500 - Internal server error.</title>
<style type="text/css">
<!--
body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}
fieldset{padding:0 15px 10px 15px;}
h1{font-size:2.4em;margin:0;color:#FFF;}
h2{font-size:1.7em;margin:0;color:#CC0000;}
h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;}
#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS", Verdana, sans-serif;color:#FFF;
background-color:#555555;}
#content{margin:0 0 0 2%;position:relative;}
.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}
-->
</style>
</head>
<body>
<div id="header"><h1>Server Error</h1></div>
<div id="content">
<div class="content-container"><fieldset>
  <h2>500 - Internal server error.</h2>
  <h3>There is a problem with the resource you are looking for, and it cannot be displayed.</h3>
</fieldset></div>
</div>
</body>
</html>

Offline

#6 2019-06-18 19:49:46

LaDenrée
HELPER
Registered: 2012-11-19
Posts: 4,658

Re: RESTful API usage for ticket update

Mistype  in url tikcet should be Ticket


Trouver la panne avant de réparer...
*GLPI 9.1.6+fusion9.1+1.1+behaviours1.5.0+reports+fields+appliances+pdf+badges+formcreator2.5.2 PHP7.0 Mariadb10
*GLPI 9.4.3(behaviours2.2.1+fusioninventoty 9.4+1.1+applicatifs2.5.0+fields 1.9.1)hebergé sur serveur mutualisé.

Offline

Board footer

Powered by FluxBB