Forums

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

JQL via API gives 400 but works in browser

Angela Brown April 9, 2025

Hello! I'm trying to do a JQL search through python, but having problems. I've successfully used the API to access a single issue, so I know the authentication is okay.

This works in my browser: https://<base-url>.atlassian.net/rest/api/3/search?jql=project = "CHOR" AND due >= "2025-04-07" AND due <= "2025-04-13" ORDER BY created DESC

And this is my python code (I simplified the JQL in case that was the issue):

searchURL = 'https://<base-url>.atlassian.net/rest/api/3/search'
jql = 'project = "CHOR"'
urlJQL = searchURL + '?jql=' + jql

auth = HTTPBasicAuth(email, token)
headers = {
"Accept": "text/html,application/json",
"Content-Type": "application/json"}
response = requests.request( "POST", urlJQL, headers=headers, auth=auth )

And the response I get is:

{'errorMessages': ['No content to map to Object due to end of input']}

Can somewhat help me figure out what I'm missing?

1 answer

1 accepted

5 votes
Answer accepted
David Nickell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 9, 2025

I would guess it is one of two things:

  1. I believe the search endpoint is a GET not a POST (otherwise it wouldn't work in the browser)
  2. The format of your authorization .. When I make my calls from Power Query, the Authorization header looks like what I have pasted below. 
    1. The really long string is Base64 encoded of my userid:apipkey
    2. I then use  https://base64encode.com/  to encode it.
    3. Be certain not to overlook the colon!!!  ":"  

Here is what the final header looks like

Authorization=Basic ZG5pY2tlbGxAc.......aRHFFMUxUNnpmNEZlclZJPUMwOTdEREFF

If this doesn't fix it --- feel free to plug your praramters into my excel sheet on my website (splitdimedata.com).  that might help you determine if your API key is the issue.

Thanks

Angela Brown April 9, 2025

The GET was the issue! I had originally thought that searching with JQL was a post and I guess I never fixed that part of it. Thank you so much :)

Like David Nickell likes this
Charlie Misonne
Community Champion
April 10, 2025

If I may add something to this:

There are 2 methods for the search endpoint: POST and GET.

With GET you need to use the query parameter like you did. With POST you need to use the request body, that's why the POST did not work for you.

I can also recommend using /rest/api/3/search/jql instead of /rest/api/3/search. The latter has been deprecated.

Link to the GET endpoint to be used: The Jira Cloud platform REST API

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
TAGS
AUG Leaders

Atlassian Community Events