代码之家  ›  专栏  ›  技术社区  ›  Ekaterina Premudraya

无法通过python JIRA库连接到JIRA api

  •  2
  • Ekaterina Premudraya  · 技术社区  · 7 年前

    我无法通过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 回复  |  直到 7 年前
        1
  •  2
  •   Max    7 年前

    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/'})