使用具有RESOURCE_STATUS的python-rtkit在RT中创建票证:需要401个凭据 [英] Create ticket in RT with python-rtkit having RESOURCE_STATUS: 401 Credentials required
问题描述
我是新来的.这是与这个问题相同的问题,但是我没有得到答案,所以我再次发布了它:
I'm new here. It's the same question as this one, but I didn't get answer so I post it again: how to create a ticket in rt using python-rtkit
我同时尝试了CookieAuthenticator
和BasicAuthenticator
来创建或读取票证,但是我仍然遇到相同的错误:
I tried both CookieAuthenticator
and BasicAuthenticator
to create or read ticket but I still get the same error:
`RT/3.8.13 401 Credentials required`
When I load the url directly in the browser: http://ticket.corp.kk.net/REST/1.0/ticket/214560?user=user&pass=pass, I DO get the ticket content in the browser.
我什至尝试使用wget
命令使用cookie来获取一个票证内容,如下所示,并且效果很好:
I even tried the wget
command to get one ticket content as below using cookie, and it works well:
-
在
coookie.txt
文件中手动保存cookie值:
save manually the cookie value in the
coookie.txt
file:
RT_SID_kk.net.80=5a1c1eb207c4e2ef5af726e98d751a08
运行此命令:
run this command:
wget -O ticketContent.txt --keep-session-cookies --save-cookies cookies.txt 'http://ticket.corp.kk.net/REST/1.0/ticket/220680/show?format=l&user=user&pass=pass'
票证内容已在ticketContent.txt
中很好地注册,这表明使用cookie进行身份验证是有效的.
The ticket content is well registered in ticketContent.txt
, which is showing using the cookie to authenticate is working.
但是我仍然无法在我的python脚本中通过rtkit的CookieAuthentication
.
But I still can not go through CookieAuthentication
of rtkit in my python script.
我在这个问题上苦苦挣扎了2天,如果有人可以帮助我,我将深表感谢.谢谢.
I've been struggling on this problem for 2 days, I would deeply appreciate it if someone can help me out. Thank you.
推荐答案
我没有找到解决此问题的方法,但是我成功使用python Requests库在RT中创建了票证.
I haven't found a solution for this problem , but I succeeded to use python Requests library to create a ticket in RT .
- 安装请求库. http://docs.python-requests.org/en/latest/用户/安装/#install
-
在RT中创建新票证
- install Requests lib. http://docs.python-requests.org/en/latest/user/install/#install
create a new ticket in RT
#!/usr/bin/python -u
import requests,logging
logging.basicConfig(level=logging.DEBUG)
post_data = """
id: ticket/new
Queue: myqueue
Subject: Test Ticket creation in RT with Python
Text: Wow ticket is created :-D .
"""
payload = {'user': 'user', 'pass': 'password','content':post_data}
ticket_creation_reusult = requests.post("http://ticket.corp.kk.net/rt3/REST/1.0/ticket/new", payload)
logging.debug(ticket_creation_reusult.text)
输出为:
INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): ticket.corp.kk.net
DEBUG:requests.packages.urllib3.connectionpool:"POST /rt3/REST/1.0/ticket/new HTTP/1.1" 200 None
DEBUG:root:RT/3.8.13 200 Ok
# Ticket 221173 created.
如果您和我有同样的问题,希望可以为您提供帮助. :-)
Hope this can help you , if you have the same problem as me . :-)
这篇关于使用具有RESOURCE_STATUS的python-rtkit在RT中创建票证:需要401个凭据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!