Skip to content
Snippets Groups Projects

PyOTRS

build status

Use

import pyotrs or from pyotrs import Article, Attachment, Client, DynamicField, Ticket

Example

  • instantiate a Client object called client
  • create a session ("login") on client
  • get the Ticket with ID 1
  • add an Article to Ticket with ID 1
>>> from pyotrs import Article, Client, Ticket
>>> client = Client("http://otrs.example.com", "GenericTicketConnectorREST", "root@localhost", "password")
>>> client.session_create()
True

>>> client.ticket_get_by_id(1)
True
>>> client.result_list_ticket_get
[<Ticket: 1>]
>>> my_ticket = client.result_list_ticket_get[0]

>>> my_ticket.TicketNumber
u'2010080210123456'
>>> my_ticket.Title
u'Welcome to OTRS!'
>>> my_ticket.to_dct()  # Show complete ticket

>>> my_article = Article({"Subject": "Subj", "Body": "New Body"})
>>> client.ticket_update(1, article=my_article)
True

Get Articles and Attachments

>>> client.ticket_get_by_id(1, articles=1, attachments=1)  # include Articles and Attachments
>>> my_ticket = client.result_list_ticket_get[0]

>>> my_ticket.list_articles
[<ArticleID: 3>, <ArticleID: 3>

>>> my_ticket.list_dynamic_field
[<DynamicField: ProcessManagementActivityID: None>, <DynamicField: ProcessManagementProcessID: None>]

Useful result data

  • client.result_list_ticket_get (list) - list of ticket_get results
  • client.result_list_ticket_search (list) - list of ticket_search results
  • client.result_json (dict) - full result set as dict

Tips

ipython

import sys
reload(sys)
sys.setdefaultencoding('utf-8')

Full Docs

The Docs are hosted here: https://sys.denm.de/PyOTRS/docs/

Dist

The Docs are hosted here: https://sys.denm.de/PyOTRS/dist/

Coverage

The Docs are hosted here: https://sys.denm.de/PyOTRS/htmlcov/