无法通过python-jira lib连接到JIRA-api

时间:2017-09-11 04:46:02

标签: python jira-rest-api

我无法对python-jira进行身份验证 我尝试使用https://pypi.python.org/pypi/jira/ 根据我使用的文档

from jira import JIRA

jira = JIRA('https://pm.maddevs.co/') # I am not sure if it is correct to use our site server or jiras

username = 'my_user_name'
password = 'my_pass'
authed_jira = JIRA(basic_auth=(username, password))

我错了

WARNING:root:HTTPConnectionPool(host='localhost', port=2990): Max retries exceeded with url: /jira/rest/api/2/serverInfo (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f8a7e228198>: Failed to establish a new connection: [Errno 111] Connection refused',)) while doing GET http://localhost:2990/jira/rest/api/2/serverInfo [{'headers': {'X-Atlassian-Token': 'no-check', 'Content-Type': 'application/json', 'Accept-Encoding': 'gzip, deflate', 'Cache-Control': 'no-cache', 'Connection': 'keep-alive', 'Accept': 'application/json,*.*;q=0.9', 'User-Agent': 'python-requests/2.18.4'}, 'params': None}]
WARNING:root:Got ConnectionError [HTTPConnectionPool(host='localhost', port=2990): Max retries exceeded with url: /jira/rest/api/2/serverInfo (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f8a7e228198>: Failed to establish a new connection: [Errno 111] Connection refused',))] errno:None on GET http://localhost:2990/jira/rest/api/2/serverInfo
{'response': None, 'request': <PreparedRequest [GET]>}\{'response': None, 'request': <PreparedRequest [GET]>}
WARNING:root:Got recoverable error from GET http://localhost:2990/jira/rest/api/2/serverInfo, will retry [1/3] in 17.18299613314676s. Err: HTTPConnectionPool(host='localhost', port=2990): Max retries exceeded with url: /jira/rest/api/2/serverInfo (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f8a7e228198>: Failed to establish a new connection: [Errno 111] Connection refused',))

1 个答案:

答案 0 :(得分:2)

您应该使用以下格式连接到服务器:

jira = JIRA(basic_auth=(un, pwd), options={'server': server})

所以你的代码就像这样:

from jira import JIRA

username = 'my_user_name'
password = 'my_pass'
jira = JIRA(basic_auth=(username, password), options = {'server': 'https://pm.maddevs.co/'})