Creating a Ticket with Custom Field using Python rt

Hi I’m using the Python rt to create tickets. I’m having a Custom field as CF.{ISMS Type}, according to the python rt if we want to set the custom field we should follow this,

Custom fields CF.{} could be set
with keywords CF_CustomFieldName.

here is the function for creating the ticket

def create_ticket(self, Queue: typing.Optional[typing.Union[str, object]] = None,
files: typing.Optional[typing.List[typing.Tuple[str, typing.IO, typing.Optional[str]]]] = None,
**kwargs: typing.Any) → int:

So how could i set the custom field when I’m creating the ticket ?

import rt

tracker = rt.Rt('http://foundation/REST/1.0/', 'root', 'password')
tracker.login()

tracker.create_ticket(Queue='General', \
  Subject='Coffee (important)', \
  Text='Help I Ran Out of Coffee!', \
  CF_Dog='Woof'
)

That works for me

My custom field is ‘ISMS Type’, I’m bit confused since it is 2 words, so how do i mention it there ?

I am not familiar with ISMS, but for Python3 to have a space in the kwargs you can use a dictionary:

args = {
  'Queue':'General',
  'Subject':'Coffee (important)',
  'Text':'Help I Ran Out of Coffee!',
  'CF_One Two':'Woof'
}

tracker.create_ticket(**args)
1 Like

Thanks for your support It Works! :slightly_smiling_face: