我正在尝试使用 python-rtkit 在 RT 中创建票证,它提供200 OK
并返回实际上并未在 RT 中创建的空票证的信息,另外我直接尝试使用 requests 模块,结果相同也是。
我的代码尝试使用请求模块
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)
我的代码尝试使用请求 python-rtkit,
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)
输出:
[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', '')]]
看起来它正在创建一张空票;但是网络界面中没有显示任何内容,这些是 python-rtkit 的示例和我从这里找到的另一个示例,但结果相同