pythonotrsticket-system

How to close a OTRS ticket using pyotrs in python?


I am new to ticketing system - OTRS. I can successfully create a OTRS ticket using pyotrs, also access ticket attributes like ticket number etc. However, I dont have any idea how to close a ticket using otrs ticket-id or ticket number. On close inspection in OTRS documentation I got the following - "Attention: PyOTRS can only retrieve Ticket data at the moment!".

So any suggestion as to how to close an OTRS ticket with or without python (non-GUI)?


Solution

  • I assume you already have a webservice named "GenericTicketConnectorREST" (because of the pyotrs example webservice). In there you need to have an operation called TicketUpdate (last entry in the image). enter image description here

    Under "Configuration" you should add/change the entry for TicketUpdate (i had to change it):

    enter image description here

    Using Postman (or any tool to send your rest request) you can send the following JSON to close a Ticket. Remember to set the Postman request to Patch, as it is set in the configuration.

    {
       "UserLogin":"root@localhost",
       "Password":"root",
       "TicketID":"1",
       "Ticket":{
          "State": "closed successful"
       },
       "Article":{
          "ContentType":"text/plain; charset=utf8",
          "Subject":"Ticket closed",
          "Body":"Ticket closed"
       }
    }
    

    The URL Depends on the name of your webservice and how you set the routing (TicketUpdate). http://localhost/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnectorREST/TicketUpdate. You can change anything listed in the api for the operation "TicketUpdate". Eveything under the key Data is something you can add to change. https://doc.znuny.org/doc/api/otrs/6.0/Perl/Kernel/GenericInterface/Operation/Ticket/TicketUpdate.pm.html