Glpi: Question - Create a ticket through the GLPI's API

Created on 1 Jun 2017  路  5Comments  路  Source: glpi-project/glpi

Hi, I was looking at the documentation for the API in the version 9+.
I can`t find the procedure to create a ticket manually through the API.

I am not sure if I should use CreateItems(https://fossies.org/dox/glpi-9.1.3/classAPI.html#ac7f13f8b6f29aa2ac95226eecb6f1fd6) or CreateTicket(https://fossies.org/dox/glpi-9.1.3/classTicketRecurrent.html#acd62a67b699bec6f0223c0de9153562b).

More information about what exactly I am trying to do:
We have an homemade .NET app. We want to use the GLPI`s API inside our custom APP to create tickets. At the same time, we would like to fill the ticket's basic information (title, description, watchers, assigned, few more) - nothing too fancy

May someone provide me few hints/advice to do this ?

Thank you :D

Most helpful comment

here some simple ticket
{
$titre='MyTitle';
$description='MyContent';

$ch = curl_init();
$url=glpi/apirest.php/Ticket/";
    $fields='{
"input": {
    "name": "' .$titre. '","requesttypes_id": "1","content": "'.$description.'","type": "1"
}

}';

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, $fields);
$request_result = curl_exec($ch);
curl_close ($ch);
$obj = json_decode($request_result,true);
$ticket_id=$obj['id'];

}?>

All 5 comments

Is it possible to have some help on this? It would be greatly appreciated ! 馃

have a look to glpi forums, you might get some help

http://forum.glpi-project.org/viewtopic.php?id=157519

here some simple ticket
{
$titre='MyTitle';
$description='MyContent';

$ch = curl_init();
$url=glpi/apirest.php/Ticket/";
    $fields='{
"input": {
    "name": "' .$titre. '","requesttypes_id": "1","content": "'.$description.'","type": "1"
}

}';

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, $fields);
$request_result = curl_exec($ch);
curl_close ($ch);
$obj = json_decode($request_result,true);
$ticket_id=$obj['id'];

}?>

Alright! Thx, I will take a look at this. (Good thing I speak french)

Closing fro now. Feel free to reopen if there really is an issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ymfinidori picture ymfinidori  路  5Comments

stonebuzz picture stonebuzz  路  3Comments

iaanpermana picture iaanpermana  路  4Comments

Megachip picture Megachip  路  6Comments

btry picture btry  路  3Comments