为什么 IBM RTC HTTP GET 请求的 rtcclient `getWorkitem()` 返回不正确的响应?
Why is the rtcclient `getWorkitem()` for IBM RTC HTTP GET request returning incorrect response?
我正在尝试使用 rtcclient Python package 从我的 IBM RTC 板上验证和检索工作项。具体来说,我的目标是 运行 这个命令没有错误:
myclient.getWorkitem("202007")
其中 202007 是 'epic' 票证的 ID。
每当我尝试 运行 我的程序时,我最终都会遇到 XML 解析错误,其中 rtcclient 向 URL 发出 GET 请求并期望收到 XML 数据,但只在 resp.content
.
中显示 HTML
例如,如果我启动 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"
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'}
请求完成后,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 数据并验证是否可以这样做?
首先检查这是否适用于 0.6.0(取决于您的 RTC 版本 6.x?;7.x)。
dixudx/rtcclient
issue 136 提及:
v0.7.0 has introduced a change on authentication, refer to #133 for details (and issue 112), which may be not compatible with older Rational Team Concert. From your issue, it seems to be true. Sorry for this.
My suggestion is just sticking with older rtcclient version, such as pip install rtcclient==0.6.0
.
我正在尝试使用 rtcclient Python package 从我的 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"
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'}
请求完成后,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 数据并验证是否可以这样做?
首先检查这是否适用于 0.6.0(取决于您的 RTC 版本 6.x?;7.x)。
dixudx/rtcclient
issue 136 提及:
v0.7.0 has introduced a change on authentication, refer to #133 for details (and issue 112), which may be not compatible with older Rational Team Concert. From your issue, it seems to be true. Sorry for this.
My suggestion is just sticking with older rtcclient version, such as
pip install rtcclient==0.6.0
.