Creating a ticket using python-rtkit

I am trying to create a ticket in RT using python-rtkit, it gives 200 OKand returns information for an empty ticket that is not actually created in RT, in addition, I tried directly using the request module, and this also had the same result.

My code is trying to use the query module

post_data = """
id: ticket/new
Queue: myqueue
Subject: Test Ticket creation in RT with Python
Text: Wow ticket is created :-D . 
"""
payload = {'content':post_data}
ticket_creation_reusult = requests.post("http://rt.domain.com/REST/1.0/ticket/new"+"user="+user+"&pass="+pas, payload)

My code is trying to use python-rtkit requests,

content = {
    'content': {
        'Queue': 1,#'', 2
        'Subject': 'New Ticket',
        'Text': 'My useless\ntext on\nthree lines.',
    }
}
try:
    response = resource.post(path='ticket/new', payload=content)
    logger.info(response.parsed)
except RTResourceError as e:
    logger.error(e.response.status_int)
    logger.error(e.response.status)
    logger.error(e.response.parsed)

Output:

[DEBUG] POST ticket/new
[DEBUG] {'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8','Accept': 'text/plain'}
[DEBUG] 'content=Queue: 1\nText:My+useless%0A+text+on%0A+three+lines.\nSubject: New Ticket'
[INFO] POST
[INFO] http://nocrt.domain.com/REST/1.0/ticket/new
[DEBUG] HTTP_STATUS: 200 OK
[DEBUG] 'RT/4.2.9 200 Ok\n\n# Required: id, Queue\n\nid: ticket/new\nQueue:General\nRequestor: svc_nocrt\nSubject: \nCc:\nAdminCc:\nOwner: \nStatus:new\nPriority: 5\nInitialPriority:5\nFinalPriority: 1\nTimeEstimated: 0\nStarts: 2015-07-2014:20:07\nDue: 2015-07-27 14:20:07\nAttachment: \nText: \n\n'
[DEBUG] RESOURCE_STATUS: 200 Ok
[INFO] [[('id', 'ticket/new'), ('Queue', 'General'), ('Requestor','svc_nocrt'), ('Subject', ''), ('Cc', ''), ('AdminCc', ''),('Owner', ''), ('Status', 'new'), ('Priority', '5'), ('InitialPriority', '5'),('FinalPriority', '1'), ('TimeEstimated', '0'), ('Starts', '2015-07-2014:20:07'), ('Due', '2015-07-27 14:20:07'), ('Attachment', ''), ('Text', '')]]
[INFO] [[('id', 'ticket/new'), ('Queue', 'General'), ('Requestor','svc_nocrt'), ('Subject', ''), ('Cc', ''), ('AdminCc', ''),('Owner', ''), ('Status', 'new'), ('Priority', '5'), ('InitialPriority', '5'),('FinalPriority', '1'),('TimeEstimated', '0'), ('Starts', '2015-07-2014:20:07'),('Due', '2015-07-27 14:20:07'), ('Attachment', ''), ('Text', '')]]

It looks like he is creating an empty ticket; but nothing is displayed in the web interface, these are examples for python-rtkit, and the other I found from here , but it gives the same result

+4
source share
1 answer

Unlike your expectation, this is actually an error message.

, ( 92-105), , . , ( 128-184).

, . rtkit , rtkit docs . , - RTResource -, .

, . , , ? , .

, , afradi, .

0

Source: https://habr.com/ru/post/1598700/


All Articles