Hi,
I have been banging my head for a couple of days now and have not been able to access Jira through API using Atlassian or Jira python library. I have created a personal token which I use to pass to the server but no luck. I see Many posts here about 401 error but have not found a fix. Can anybody here help?
Here is my code:
1) I installed library - pip install atlassian-python-api (same if I wanted to use Jira library)
2) Access the information:
welcome to the community and thank you for your question.
Please try the following code and replace the parts in <> accordingly:
from atlassian import Jira
import json
jira_url = 'https://<sitename>.atlassian.net'
username = '<useraccount>'
api_token = "<token>"
jira = Jira(url=jira_url, username=username, password= api_token,cloud=True)
results = {}
boards=jira.get_issue("COES-10")
print(boards)
Problems with your code:
@Sunny Ape just to clear things up. You referenced another python api , but not the one Mohammed is using. Might be confusing for others.
OK, thanks. So many people just use the generic phrase "Atlassian Python Library" that's it's hard to tell which one they mean.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is what was installed as I mentioned in the original note.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Mohammad Hariri
Firstly, stop banging your head on a table and start thinking like a programmer. If you have problem with your code, isolate it by trying another method.
Some other methods:
Also, try reading the Atlassian Python Jira Module document more thoroughly, as I can see at least two major faults in your request.
All of this is described in the Manage Issues section of the library's documentation.
Lastly, as has been widely reported for many years (if you do some Googling), that public Python library was built for Jira SERVER and calls only v2 endpoints, some of which are called differently in Jira CLOUD, so some of the functions simply don't work. You really, really should consider de-coupling your code's dependency on that library and use the native Python Requests library instead if you intend to interact with Jira Cloud exclusively.
Anyhow, have fun on your learning journey.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for the guidance. I tried using pure requests exactly as defined here. I am still getting 401 error. Are there any settings I am missing on the backend token configuration? Not sure what can be done. All roads end in 401 error.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you @Mohammad Hariri - Have been trying to connect Jira Cloud (corporate) from Python code.. never successful. at least 20+ combinations.
However, good old Excel VBA, was easier to connect
And we say 'Python' is most sophisticated .. haaa?
also adding @Sunny Ape
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.