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,295

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.2.4(behaviours1.5.2+fusion9.2+1.0+applicatifs2.3.0+dashboard 0.8.9)hebergé sur serveur mutualisé.
*GLPI 9.3.3  en test (ubuntu 18.04 mariadb 10.2.4)

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

Board footer

Powered by FluxBB