unistra / python-glpi-api

Python module for interacting with GLPI using the API.
GNU General Public License v3.0
18 stars 10 forks source link

Is there a way to create a ticket unassigned ? #3

Closed jsalatiel closed 3 years ago

jsalatiel commented 4 years ago

When I create a new ticket using: glpi.add('Ticket' , { 'name': 'TicketName , 'content': 'ticket title'} )

The ticket is created assigned to my user and with the state PROCESSING (Assigned ). Is there a way to make it unassigned and in NEW state ?

fmenabe commented 3 years ago

Hi jsalatiel, I'm sorry as I totally miss your issue a few months ago!

Basically this library wrap what is provided by the GLPI REST API (you can find some documentation here). We also don't use ticket (only the inventory part) so I have no experience of this part of GLPI. For these kind of questions, you should ask the GLPI community first (their forum and/or mailing lists)!

That said, I looked at the problem and, once I found this post, knew where to look. Tickets seems to have "special" fields allowing to set additionnal informations (the best list I could find is directly in the code here). For example, to add a ticket in the NEW state with requesters, assigments and observers:

glpi.add(
    'Ticket',
    {
        "name": "FIXME",
        "content": "FIXME",
        "_users_id_requester": [1], # Requesters set to the user with this id
        "_users_id_assign": [1, 2], # Assignements set to these users ids
        "_users_id_observer": [1, 2], # Observers set to these users ids
        "status": "1" # Seems to be hardcoded in inc/commonitilobject.class.php ...
                      # (ex: `const INCOMING      = 1; // new`)
    }
)

From the quick tests made, you can use an empty list if you don't want to fix assigments or observers (ex: "_users_id_assign": []) but at least one requester is required.