【发布时间】:2021-11-17 14:59:17
【问题描述】:
我是 Python 的新手,jira-python 库的新手,网络编程的新手,尽管我在应用程序和集成编程以及数据库查询方面确实有相当多的经验(尽管已经有一段时间了)。
使用 Python 2.7 和请求 1.0.3
我正在尝试使用这个库 - http://jira-python.readthedocs.org/en/latest/ 使用 Python 查询 Jira 5.1。我使用未经身份验证的查询成功连接,但我必须更改 client.py 中的一行,更改
我变了
self._session = requests.session(verify=verify, hooks={'args': self._add_content_type})
到
self._session = requests.session()
我不知道我在做什么,但在更改之前我收到了一个错误,在更改之后我得到了成功返回的项目名称列表。
然后我尝试了基本身份验证,以便我可以利用我的 Jira 权限并进行报告。最初也失败了。我对
做了同样的改变def _create_http_basic_session
在 client.py 中,但现在我又遇到了另一个错误。所以问题没有解决。现在我得到一个不同的错误:
HTTP Status 415 - Unsupported Media Type
type Status report
message Unsupported Media Type
description The server refused this request because the request entity is in
a format not` `supported by the requested resource for the requested method
(Unsupported Media Type).
然后我决定只使用 requests 模块做一个超级简单的测试,我相信 jira-python 模块正在使用它,这段代码似乎让我登录了。我得到了很好的回应:
import requests
r = requests.get(the_url, auth=(my username , password))
print r.text
有什么建议吗?
【问题讨论】:
-
请求在 1.0 之后破坏了一些兼容性,并且您的 jira-python 可能不兼容。我提出了一个拉取请求,并进行了一些更改以支持 requests-1.0+ bitbucket.org/bspeakmon/jira-python/pull-request/11/…
-
@Neal Caidin,请检查我的答案,因为这是 Jira 官方文档中的最新答案。