为什么 IBM RTC HTTP GET 请求的 rtcclient `getWorkitem()` 返回错误的响应?
我正在尝试使用 rtcclient Python 包 从我的 IBM RTC 板进行身份验证和检索工作项。具体来说,我的目标是运行此命令而不出现错误:
myclient.getWorkitem("202007")
其中 202007 是“epic”票证的 ID。
每当我尝试运行我的程序时,我最终都会遇到 XML 解析错误,其中 rtcclient 向 URL 发出 GET 请求并期望接收 XML 数据,但只在 resp.content
。
例如,如果我启动 Python shell 并运行这些命令:
>>> from rtcclient.utils import setup_basic_logging
>>> from rtcclient import RTCClient
>>> setup_basic_logging()
>>> myclient = RTCClient("https://rtcus1.ta.company.com/ccm", "myUsername", "myPassword", ends_with_jazz=False)
2022-02-22 16:55:55,605 DEBUG client.RTCClient: Get response from https://rtcus1.ta.company.com/ccm/authenticated/identity
2022-02-22 16:55:55,612 DEBUG urllib3.connectionpool: Starting new HTTPS connection (1): rtcus1.ta.company.com:443
2022-02-22 16:55:56,264 DEBUG urllib3.connectionpool: https://rtcus1.ta.company.com:443 "GET /ccm/authenticated/identity HTTP/1.1" 302 0
2022-02-22 16:55:56,288 ERROR client.RTCClient: Failed GET request at <https://rtcus1.ta.company.com/ccm/authenticated/identity> with response: b''
2022-02-22 16:55:56,290 DEBUG client.RTCClient: Get response from https://rtcus1.ta.company.com/ccm/authenticated/identity
2022-02-22 16:55:56,292 DEBUG urllib3.connectionpool: Starting new HTTPS connection (1): rtcus1.ta.company.com:443
2022-02-22 16:55:56,875 DEBUG urllib3.connectionpool: https://rtcus1.ta.company.com:443 "GET /ccm/authenticated/identity HTTP/1.1" 302 0
2022-02-22 16:55:56,886 ERROR client.RTCClient: Failed GET request at <https://rtcus1.ta.company.com/ccm/authenticated/identity> with response: b''
>>> myclient.getWorkitem("202007")
执行 getWorkItem 后,它将在 rtcclient/rtcclient/client.py 文件的第 909 行运行此代码
resp = self.get(req_url, verify=False, proxies=self.proxies, headerss=self.headers)
,其中:
- req_url= “https://rtcus1.ta.company.com/ccm/oslc/workitems/202007”
代理=无
标题= {'Content-Type': 'text/xml', 'Cookie': 'WASReqURL=https:///ccm/authenticated/identity;路径=/;安全的;仅 Http; WASReqURL=https:///ccm/authenticated/identity;路径=/;安全的; HttpOnly', 'Accept': 'text/xml'}
请求完成后,resp.content
的值是一个长 HTML 字符串,其中包含 'Loading...' 和 ' >Javascript 在您的浏览器中被禁用或不可用':
b'<!DOCTYPE html>\n<!--\n \n-->\n\n<html >\n<head>\n<meta http-equiv="content-type" content="text/html; charset=UTF-8">\n<meta http-equiv="X-UA-Compatible" content="IE=10">\n<title></title>\n\n<lin...... ody>\n</html>\n'
但是,如果我在浏览器中使用相同的凭据登录到 req_url
,我会看到有效的 XML 数据;这是我需要 rtcclient 获取的数据:
但相反,它会获取 HTML 数据,这会扰乱程序并阻止我获取工作项。有谁有解决方案或知道如何在邮递员中向 RTC XML URL 发出请求以获取 XML 数据并验证是否可以这样做?
I am trying to use the rtcclient Python package to authenticate and retrieve work items from my IBM RTC board. Specifically my goal is to run this command without errors:
myclient.getWorkitem("202007")
where 202007 is the id of an 'epic' ticket.
Whenever I try to run my program, I end up facing an XML parsing error, where rtcclient makes a GET request to a URL and expects to receive an XML data, but instead only shows HTML in the resp.content
.
For example, if I start my Python shell and run these commands:
>>> from rtcclient.utils import setup_basic_logging
>>> from rtcclient import RTCClient
>>> setup_basic_logging()
>>> myclient = RTCClient("https://rtcus1.ta.company.com/ccm", "myUsername", "myPassword", ends_with_jazz=False)
2022-02-22 16:55:55,605 DEBUG client.RTCClient: Get response from https://rtcus1.ta.company.com/ccm/authenticated/identity
2022-02-22 16:55:55,612 DEBUG urllib3.connectionpool: Starting new HTTPS connection (1): rtcus1.ta.company.com:443
2022-02-22 16:55:56,264 DEBUG urllib3.connectionpool: https://rtcus1.ta.company.com:443 "GET /ccm/authenticated/identity HTTP/1.1" 302 0
2022-02-22 16:55:56,288 ERROR client.RTCClient: Failed GET request at <https://rtcus1.ta.company.com/ccm/authenticated/identity> with response: b''
2022-02-22 16:55:56,290 DEBUG client.RTCClient: Get response from https://rtcus1.ta.company.com/ccm/authenticated/identity
2022-02-22 16:55:56,292 DEBUG urllib3.connectionpool: Starting new HTTPS connection (1): rtcus1.ta.company.com:443
2022-02-22 16:55:56,875 DEBUG urllib3.connectionpool: https://rtcus1.ta.company.com:443 "GET /ccm/authenticated/identity HTTP/1.1" 302 0
2022-02-22 16:55:56,886 ERROR client.RTCClient: Failed GET request at <https://rtcus1.ta.company.com/ccm/authenticated/identity> with response: b''
>>> myclient.getWorkitem("202007")
After executing getWorkItem
, it will run this code around line 909 of the rtcclient/rtcclient/client.py file
resp = self.get(req_url, verify=False, proxies=self.proxies, headerss=self.headers)
where:
req_url="https://rtcus1.ta.company.com/ccm/oslc/workitems/202007"
proxies = None
headers = {'Content-Type': 'text/xml', 'Cookie': 'WASReqURL=https:///ccm/authenticated/identity; Path=/; Secure; HttpOnly; WASReqURL=https:///ccm/authenticated/identity; Path=/; Secure; HttpOnly', 'Accept': 'text/xml'}
After the request completes, the value of resp.content
is a long HTML string which contains 'Loading...' and '>Javascript is either disabled or not available in your Browser':
b'<!DOCTYPE html>\n<!--\n \n-->\n\n<html >\n<head>\n<meta http-equiv="content-type" content="text/html; charset=UTF-8">\n<meta http-equiv="X-UA-Compatible" content="IE=10">\n<title></title>\n\n<lin...... ody>\n</html>\n'
But if I go to the req_url
in my browser where I have logged in with the same credentials, I see valid XML data; this is the data I need rtcclient to fetch:
But instead, it fetches that HTML data which messes up the program and prevents me from fetching work items. Does anyone have a solution or know how I could make a request to my RTC XML URL in postman to fetch the XML data and verify it is possible to do so?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先检查这是否适用于 0.6.0(取决于您的 RTC 版本 6.x?;7.x)。
dixudx/rtcclient
问题 136 提到:Check first if this was working with 0.6.0 (depending on your RTC version 6.x?; 7.x).
dixudx/rtcclient
issue 136 mentions: