"Error in the JQL Query: Expecting either 'OR' or 'AND' but got ','

Anuja Lad November 30, 2017

Hi! I am newbie here!
I am trying to get issues by passing some parameters using JQL.
First, I am building normal string for jql 

e.g jqlExpr:::::::: project=Jira&fields=id,key,project,assignee,description,summary,status,priority,reporter,created,updated,issuetype,subtasks&maxResults=-1&assignee=abc

After encoding it with java method : #[java.net.URLEncoder.encode(flowVars.jqlExpr)]

also  i am setting the encoding as 'ISO 10646/Unicode(UTF-8)'
I am passing it the request call as: 

https://<host>/rest/api/2/search?jql=project%3DJira%26fields%3Did%2Ckey%2Cproject%2Cassignee%2Cdescription%2Csummary%2Cstatus%2Cpriority%2Creporter%2Ccreated%2Cupdated%2Cissuetype%2Csubtasks%26maxResults%3D-1%26assignee%3Dabc


Error message i am getting :
Error: {
"errorMessages": [
"Error in the JQL Query: Expecting either 'OR' or 'AND' but got ','. (line 1, character 21)"
],
"errors": {}
}

 

I am not able to understand what's going wrong and how can I resolve?


I appreciate your response.Thanks! 

2 answers

1 accepted

1 vote
Answer accepted
Warren
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.
November 30, 2017

Hi Anuja

assignee=abc is part of the jql, but you've got it as a parameter being passed to the API. Try

jql=project=Jira AND assignee=abc&fields=id,key,project,assignee,description,summary,status,priority,reporter,created,updated,issuetype,subtasks&maxResults=-1

If you still get an error, try copying just the JQL bit (i.e. everything after jql= up to and excluding the first &) into a Jira query and see if there are any errors

Anuja Lad November 30, 2017

Hello Warren,

Thanks a lot! 
the best answer! it  did not only just resolve the error but also helpful in a way to connect the dots here. 


I tried to use JIRA's UI to search issues to know url--> concluded that it should be encoded but JIRA's UI allowed only these two Fields 'project' and 'assignee' in advanced search issue text field, wondering why it wont allow 'fields=id,key..etc'  
Now i got what JQL is! 

so no need to do encoding in this case!

Like Rushik Pandya likes this
Shamreedak July 6, 2020

can you help me through Excel codes

Kondal A September 3, 2020

Hi Warren,

 

The same query is not working for me. It gives me a project that does not exist even though it existed. I am the admin of this Jira account, but still not able to retrieve the data. I am using basic authentication. The same query is working fine from Jira UI. Can you please help me out?

Here is the output:

<Response [400]>
{
"errorMessages": [
"The value 'XXX' does not exist for the field 'project'."
],
"warningMessages": []
}

 

Thanks in advance.

Warren
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.
September 3, 2020

Hi @Kondal A 

To help me help you, could you please give the full API call that you're trying to use? (Anonymise your project name if you want). Also, have you been able to successfully run other API calls?

Kondal A September 4, 2020

Hi @Warren 

Thank you for your quick response. No, I did not try other API calls, I just tried the below API as I need to try jql and search for the project data.

https://my-test.atlassian.net/rest/api/2/search?jql=project=TEST
response = requests.request(
'GET',
url,
headers=headers,
auth=auth
)
print(response)
print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")))

The above API returns the project not exist error.

Thank you! 

Warren
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.
September 6, 2020

Hi @Kondal A 

So just to confirm, you've typed 

project=TEST

into the filter section within Jira and it returns something?

If so, try running the API without the jql for now, i.e.

https://my-test.atlassian.net/rest/api/2/search

and then try

https://my-test.atlassian.net/rest/api/2/search?jql=key=ABC-123

where ABC-123 is the key of an issue that you know you can view within Jira.

Let me know what happens with those.

Another question, you said you're using basic auth, can you explain exactly what you're using for that? Email address? Password? API token?

Kondal A September 9, 2020

Hi Warren,

Sorry for the late reply. I am able to retrieve the data, I was using wrong username. In the basic auth I just used username and API token.

Thanks!

0 votes
Warren
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.
November 30, 2017

fields= is not part of JQL, it is what the API uses to know which fields to report on. The equivalent in the Jira issues screen is the Columns dropdown where you choose which fields (columns) to show

Anuja Lad November 30, 2017

yes, tried that too and it didn't get added in the url,,just changed on the screen

Suggest an answer

Log in or Sign up to answer