与
python --version
Python 3.8.0
只是试图解决一些问题。
from jira import JIRA
def main():
options = {'server':"https://jira.test.com/" }
jira = JIRA(options, basic_auth=('username', 'password'))
issue = jira.issue('XXXX-10085')
print (issue.fields.project.key)
print (issue.fields.issuetype.name)
print (issue.fields.reporter.displayName)
print (issue.fields.summary)
print (issue.fields.project.id)
if __name__== "__main__" :
main()
但我得到错误:
WARNING:root:Bug https://jira.atlassian.com/browse/JRA-59676 trying again...
WARNING:root:Bug https://jira.atlassian.com/browse/JRA-59676 trying again...
WARNING:root:Bug https://jira.atlassian.com/browse/JRA-59676 trying again...
Traceback (most recent call last):
File "/Users/syedahmed/ANACONDA/anaconda3/envs/jira/lib/python3.8/site-packages/jira/client.py", line 474, in __init__
self._version = tuple(si['versionNumbers'])
KeyError: 'versionNumbers'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "jt.py", line 14, in <module>
main()
File "jt.py", line 5, in main
jira = JIRA(options, basic_auth=('username', 'password'))
File "/Users/syedahmed/ANACONDA/anaconda3/envs/jira/lib/python3.8/site-packages/jira/client.py", line 476, in __init__
logging.error("invalid server_info: %s", si)
AttributeError: 'bool' object has no attribute 'error'
自从我查看源代码(client.py)以来,@ Prabhat似乎没有获得REST API的版本号。
self.deploymentType = None
470 if get_server_info:
471 # We need version in order to know what API calls are available or not
472 si = self.server_info()
473 try:
474 self._version = tuple(si['versionNumbers'])
475 except Exception as e:
476 logging.error("invalid server_info: %s", si)
477 raise e
478 self.deploymentType = si.get('deploymentType')
479 else:
480 self._version = (0, 0, 0)
在浏览器中,打开https://jira.test.com/rest/api/2/issue/XXXX-10085时,我会获得正确的JSON
但是当我使用curl时,我得到了AUTHENTICATION_DENIED
$ curl -D- -X GET -H "Authorization: Basic base64encodedhash" -H "Content-Type: application/json" "https://jira.test.com/rest/api/2/issue/XXXX-10085"
HTTP/1.1 200
X-AREQUESTID: 1239x574427x1
X-ANODEID: node2
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
Content-Security-Policy: frame-ancestors 'self'
X-ASEN: SEN-6742665
Set-Cookie: JSESSIONID=487ECA3C5601199AB97294A8BA866151; Path=/; HttpOnly
X-Seraph-LoginReason: AUTHENTICATION_DENIED
Content-Type: text/html;charset=UTF-8
Content-Length: 0
Date: Tue, 31 Dec 2019 01:39:14 GMT
Set-Cookie: BIGipServerJIRA=67143434.36895.0000; path=/; Httponly; Secure
Strict-Transport-Security: max-age=63072000; includeSubDomains; preload
Set-Cookie: TS01dc5b77=015efd37d830c3fc1357c099281a755d6a9e2fc387d6a6c5af8aead0625e8a81e65afe21e442cd23510d7f30577b4ec345e82490c436146235e475a8d6f0a92a1e4159712c3ac6e13dbe26719fd07ac6ec48b466bd; Path=/
请记住,我正在对用户名:密码使用base64哈希
URL和用户凭据似乎没有错。请检查您尝试访问的服务器和凭据详细信息。
options = {'server':"https://jira.test.com/" }
jira = JIRA(options, basic_auth=('username', 'password'))
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句