You are not logged in.
Hi Everybody,
I am using Add-Items to dynamically add a Ticket in GLPI. (https://fossies.org/dox/glpi-9.1.4/md_a … #add-items)
So far, I can add the ticket without any problem.
Here is how my class look:
Public Class GLPITicket
Public name As String
Public content As String
Public status As String
Public urgency As String
Public _disablenotif As Boolean
End Class
Then I serialize my object in json. The final result look like this:
{"input": {"name": "Ticket Name", "content": "Ticket Desc","status":"1","urgency":"1","_disablenotif":true}}
So far, so good.
The next step is to assign a user and a group of watcher.
The thing is, I can't find the name of these properties... Any idea how you could do that ?
Thank you
Last edited by hypemonkey (2017-06-28 16:00:42)
Offline
to assign a user :as requester
"_users_id_requester": $users_id.
tickets actors are in \Ticket_User.
\glpi\apirest.php\ticket\'.$ticket_id.'\ticket_user\
groups are in
\glpi\apirest.php\ticket\'.$ticket_id.'\Group_ticket\
Trouver la panne avant de réparer...
GLPI10.0.16 (ubuntu 22.04 PHP8.1 Mariadb10.6 ) plugins : comportements 2.7.3 reports 1.16.0 formcreator 2.13.9, datainjection 2.13.5 fields 1.21.9
Offline
So LDenree, I would I go about leveraging your information posted above to actually update a ticket's assigned user/group? Would I call those API endpoints directly to update the information? A working example would be super handy to help me wrap my head around this.
I'm doing a simple Powershell GUI tool for dynamically generating a ticket based off of form data, and I'd like a way to have the user notified when someone grabs the ticket, likely waiting for the Assigned To User/Group ID to change with another API call and a loop.
Offline
to add assigned users and assigned groups to tickets i make it so
1): initsession :
$api_url="localhost/glpi/apirest.php";
$user_token="MyUserToken";
$app_token="MyAppToken";
$ch = curl_init();
$url=$api_url . "/initSession?Content-Type=%20application/json&app_token=".$app_token ."&user_token=".$user_token;
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$json = curl_exec($ch);
curl_close ($ch);
$obj = json_decode($json,true);
$sess_token = $obj['session_token'];
$headers =array(
'Content-Type: application/json',
'App-Token: ' .$app_token,
'Session-Token: '.$sess_token
);
keep variables $headers and $sess_token for next actions
2) add assigned user ( technician) to ticket
$ticket_id="MyTicketID";
$user_id="IdOfTheTechnician";
$input='{ "input": {"tickets_id": '.$ticket_id.' ,"users_id": '.$user_id.',"type": "2","use_notification": "1"}}';
$url=$api_url . "/Ticket/".$ticket_id."/Ticket_User/";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS,$input);
$json = curl_exec($ch);
curl_close ($ch);for debug you can add :
$obj = json_decode($json,true);
echo "<br/>".$input."<br/>";
print_r($json);
$group_id="MyGroupIDto Assign";
$input='{ "input": {"tickets_id": '.$ticket_id.' ,"groups_id": '.$group_id.',"type": "2","use_notification": "1"}}';
$url=$api_url . "/Ticket/".$ticket_id."/group_ticket/";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS,$input);$json = curl_exec($ch);
curl_close ($ch);
$obj = json_decode($json,true);
echo "<br/>".$input."<br/>";
print_r($json);
note : in $input='{ "input": {"tickets_id": '.$ticket_id.' ,"groups_id": '.$group_id.',"type": "2","use_notification": "1"}}';
you can change type to
1) requester
2)assigned
3)observer
Last edited by LaDenrée (2017-09-06 14:50:46)
Trouver la panne avant de réparer...
GLPI10.0.16 (ubuntu 22.04 PHP8.1 Mariadb10.6 ) plugins : comportements 2.7.3 reports 1.16.0 formcreator 2.13.9, datainjection 2.13.5 fields 1.21.9
Offline
Hello,
I want to modify a ticket with APi rest in follow ups field, but i can't.
When i execute a command, i have not error and we don't have a word and i have not a new follow.
see my command :
curl -X PUT -H 'Content-Type: application/json' -H "Session-Token: xxxxxxxxxxxxxxxxxxxxxxxxxx" -H "App-Token: xxxxxxxxxxxxxxxxxxxxxxxxxxx" -d '{"input": {"id": 43935, "users_login":"xxxxxx", "followups": "test Donw 555ddqsdqdqs5 follow"}}' 'http://glpi-dev.test.loc/apirest.php/Ticket/'
Can you help me please ?
Thanks
Offline
please, create a new discussion.
glpi version ?
your url seems wrong : you are trying to update a ticket, you should update followup.
can you get ticket followups ?
Last edited by LaDenrée (2017-11-03 20:27:15)
Trouver la panne avant de réparer...
GLPI10.0.16 (ubuntu 22.04 PHP8.1 Mariadb10.6 ) plugins : comportements 2.7.3 reports 1.16.0 formcreator 2.13.9, datainjection 2.13.5 fields 1.21.9
Offline
Hello, i have open a new topic.
Thanks
Offline
Hi all,
How to change $user_id="IdOfTheTechnician"; to $user_name="User Name OfTheTechnician";
Thanks
Offline
you need two steps.
First use search endpoint To get userid
myserver/glpi/apirest.php/search/User?criteria[0][field]=1&criteria[0][searchtype]=contains&criteria[0][value]=^MyUserName$
Then assign userid To tickets actors
*****************************
you should create your own post, you will get more visibility so more answers. please don't duplicate questions on other posts.
Last edited by LaDenrée (2018-05-08 09:52:50)
Trouver la panne avant de réparer...
GLPI10.0.16 (ubuntu 22.04 PHP8.1 Mariadb10.6 ) plugins : comportements 2.7.3 reports 1.16.0 formcreator 2.13.9, datainjection 2.13.5 fields 1.21.9
Offline