为什么 IBM RTC HTTP GET 请求的 rtcclient `getWorkitem()` 返回错误的响应?

发布于 2025-01-09 02:48:28 字数 3133 浏览 1 评论 0原文

我正在尝试使用 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:

enter image description here

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

山有枢 2025-01-16 02:48:28

首先检查这是否适用于 0.6.0(取决于您的 RTC 版本 6.x?;7.x)。

dixudx/rtcclient 问题 136 提到:

v0.7.0 引入了身份验证方面的更改,详细信息请参阅#133(以及问题 112),这可能与旧版 Rational Team Concert 不兼容。从你的问题来看,似乎是真的。对此表示抱歉。

我的建议是坚持使用较旧的 rtcclient 版本,例如 pip install rtcclient==0.6.0

Check first if this was working with 0.6.0 (depending on your RTC version 6.x?; 7.x).

dixudx/rtcclient issue 136 mentions:

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文