0

with

python --version
Python 3.8.0

simply trying to get some issues.fields

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()

but I get error:

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'

@Prabhat seems its not getting the version # of the REST API since when I look at the source ( client.py )

 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)

In the browser I get the correct JSON when I open https://jira.test.com/rest/api/2/issue/XXXX-10085

But when I use curl, I get 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=/

keep in mind that I am using the base64 hash for username:password

2 Answers 2

1

URL and user credentials seems to be not wrong.Check the server and credential details you trying to access .

options = {'server':"https://jira.test.com/" }
jira = JIRA(options, basic_auth=('username', 'password'))
Sign up to request clarification or add additional context in comments.

2 Comments

I posted the answer
the account got disabled, and the JIRA admins did not inform me. The error was not indicative of the root cause. I plan to open a bug on the Atlassian jira board
0

ref: https://community.atlassian.com/t5/Jira-questions/How-do-I-access-the-hosted-Jira-API-via-python/qaq-p/505632

Standard basic authentication is now deprecated in Jira from June 2019.

An API key is required for basic authentication which now replaces the 'password' requirement. API key's can be generated from: https://confluence.atlassian.com/cloud/api-tokens-938839638.html.

Once the key has been obtained, replace your current Jira object with the following: jira = JIRA(basic_auth=("enter username", "enter API key"), options={'server': "enter server"}).

1 Comment

This ( the API Keys ) applies to the Cloud instance of Jira and NOT to the Server based installs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.