2

I want to list/search all the issues in Jira. I have a code like :

url = 'https://company.com/rest/api/2/search'


auth = HTTPBasicAuth("username", "password") // I tries token as well

headers = {
    'Accept': 'application/json'
}

query = {
    'jql': 'project=PRKJECTKEY',
    'startAt': 0
}
response = requests.request(
    "GET",
    url,
    headers=headers,
    auth=auth,
    params=query
) 

I am not sure if the password should be token or the actual password and the url should be should be starting from companyname.com. This gives me <Response [401]> but i have all the permissions with the account.

Can someone help me with the authentication is supposed to be used this way.

2 Answers 2

2

I can only describe my way of accessing the JIRA-API:

1. I am using an API-key for this which one can easily create online, if one has the necessary permissions

(https://developer.atlassian.com/cloud/jira/platform/basic-auth-for-rest-apis/)

2. You need to set up the Jira-object to query issues first
user = '[email protected]'

apikey = 'xxxxxxxxxxxxxxxxx'
server = 'https://companypage.atlassian.net'

options = {
 'server': server
}

jira = JIRA(options, basic_auth=(user, apikey))
3. Now, you can use the Jira-object to query with
tickets = jira.search_issues('text ~ "my search text" ORDER BY updated DESC')

Now, you can look what you got back and play with the results

for ticket in tickets:
  print(ticket)

For Packages, you only need to import JIRA at the top (obviously, need to install jira first):

from jira import JIRA
Sign up to request clarification or add additional context in comments.

Comments

1

Well, why don't you use atlassian-python-api?

https://community.atlassian.com/t5/Jira-articles/Atlassian-Python-API-s/ba-p/2091355

It's much easier to work with Jira via their own library. I have been working with Confluence via this and it's pretty simple. Take a look it may solve your problem.

EDIT: here is documentation. https://atlassian-python-api.readthedocs.io/

1 Comment

Thank you Johny for your answer :) Another answer helped me.

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.