Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

End to end Jira Rest API Python example needed

Keith Thomas
Contributor
November 3, 2025

I'm a vibe programmer with Python accessing Jira. Once I have the framework of the code I need I'm sure I'll be fine to refine it. Getting started is proving a barrier to me with the new API.

 

I can form the URL to make an initial JQL query to return issues but I don't think I'm authenticating correctly prior to the query. Is there somewhere I can look to see an up to date example of authentication and query using Python?

 

I think my query is correctly formed because when I paste it in the browser I get data back. however I get not data in my Python code. 

My authentication code snippet:

def auth_session(email, token):

      s = requests.Session()

      s.auth = (email, token)

      s.headers.update({'Accept': 'application/json'})

      return s
session = auth_session(args.user, token)

My query code snippet:

   url = base_url.rstrip('/') + '/rest/api/3/search/jql?jql=project=WD01&fields=*all'
   print(url)

   r = session.get(url)

   r.raise_for_status()

   data = r.json()
    which creates this URL: 
      https://keiththomas.atlassian.net/rest/api/3/search/jql?jql=project=WD01&fields=*all

 

1 answer

0 votes
Mohamed Benziane
Community Champion
November 4, 2025

Hi,

Did you create correctly your token : Manage API tokens for your Atlassian account | Atlassian Support

Do you have any error message when you run the script ?

Here an example from the documentation The Jira Cloud platform REST API :

 

import requests

jira_base_url = mySite.atlassian.net

query = { 'jql': 'project = HSP' }
headers = { "Accept": "application/json" }
auth = HTTPBasicAuth("email@example.com", "<api_token>")

response = requests.get(
        f"{base_url}/rest/api/3/search",
        headers=headers,
        auth=auth,
        params=query
    )
Keith Thomas
Contributor
November 4, 2025

@Mohamed Benziane thank you for the response. I took your suggestion and

1. Added an extra line:

          from requests.auth import HTTPBasicAuth

2. Added jql to the URL to avoid this error

Screenshot from 2025-11-04 11-33-02.png

As far as I can tell from the debugger I still see no issues:

Screenshot from 2025-11-04 11-41-07.png

 

Keith Thomas
Contributor
November 5, 2025

OK, Authentication looks good now I've caught all my typos. My bad. 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Product Admin Site Admin
TAGS
AUG Leaders

Atlassian Community Events