-->

Welcome to our Coding with python Page!!! hier you find various code with PHP, Python, AI, Cyber, etc ... Electricity, Energy, Nuclear Power

Wednesday, 4 July 2018

Python | Step by Step how to access the hosted Jira API via python

Using the JIRA python module this example works:

from jira import JIRA
jira = jira = JIRA(basic_auth=(un, pwd), options={'server': server})
issue = jira.issue('JRA-9')
print(issue.fields.project.key) # 'JRA'
print(issue.fields.issuetype.name) # 'New Feature'
print(issue.fields.reporter.displayName) # 'Mike Cannon-Brookes [Atlassian]'

16 comments:

  1. Hi,
    I tried this code. I am getting syntax error

    ReplyDelete
  2. you should use the following format:

    jira = JIRA(basic_auth=(un, pwd), options={'server': server})
    you need to pass in the server details as a connection option when you are specifying basic_auth.

    in the example above, un pwd and server are all string variables.

    ReplyDelete
  3. You haven't setup your dictionary correctly in the example above, you just specified the url as a key with no value, instead of a key/value pair.

    Options should be:

    options = {'server': 'https://myaccount.atlassian.net'}

    ReplyDelete
  4. For 'https://jira.mycompany.com' it is unable to authenticate. And gives 404 error

    ReplyDelete
  5. hi,
    i got the same problem to authenticate "https://jira.mycompanyname'
    with HTTP 404 error
    jira = JIRA(basic_auth=('username', 'pw'), options={'server':'https://jira.mycompany.net','verify':False})

    jira.exceptions.JIRAError: JiraError HTTP 404

    any suggestions to fix this?

    Thanks

    ReplyDelete
  6. JIRA 5.0, REST API, jira-python, Start/End Date
    https://thepythoncoding.blogspot.com/2019/07/jira-50-rest-api-jira-python-startend.html

    ReplyDelete
  7. When I try:

    jac = JIRA(basic_auth=(userID, passwd), options={'server': server+':'+port})

    I get the following error:


    WARNING:root:HTTPSConnectionPool(host=server, port=port): Max retries exceeded with url: /rest/api/2/serverInfo (Caused by SSLError(SSLError(1, u'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:661)'),)) while doing GET https://server:port/rest/api/2/serverInfo [{u'headers': {'Accept-Encoding': 'gzip, deflate', u'Accept': u'application/json,*.*;q=0.9', 'User-Agent': 'python-requests/2.22.0', 'Connection': 'keep-alive', u'X-Atlassian-Token': u'no-check', u'Cache-Control': u'no-cache', u'Content-Type': u'application/json'}, 'params': None}]

    where server and port have been provided and confirmed with our IT department... any ideas what I'm doing wrong?

    ReplyDelete
  8. Standard basic authentication is now deprecated in Jira from June 2019. An API key is required which 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"}).

    This should work as it has worked for me.

    ReplyDelete
  9. How to add API token as authentication menthod instead of providing username and password in text format

    ReplyDelete
  10. When you use a genuine service, you will be able to provide instructions, share materials and choose the formatting style. college confidence

    ReplyDelete
  11. The information which you have provided in this blog is really useful to everyone. Thanks for sharing.

    Python Training in Hyderabad

    ReplyDelete
  12. Thank you for your post. This is excellent information. It is amazing and wonderful to visit your site.
    This idea is mind blowing. I think everyone should know such information like you have described on this post. Thank you for sharing this explanation.
    oracle training in chennai

    oracle training institute in chennai

    oracle training in bangalore

    oracle training in hyderabad

    oracle training

    oracle online training

    hadoop training in chennai

    hadoop training in bangalore

    ReplyDelete

Thanks for your comments

Rank

seo