Rest/api/3/search return 400 and the same JQL is working inside JIRA

Hello I’m using /rest/api/3/search API to validate JQL which returns 400 if I passed below JQL -

JQL - issuetype = Bug and fixVersion = “1.0 & 2.0”

If i passed the same jql in jira then it works fine refer below screenshot -

1 Like

Hello @krishnashah

Do a Google search on the topic of URL special characters, like ampersands, and how to encode them inside REST API queries.

Thanks @sunnyape now we are encoding the url.

Now, search api returns below error message -

In case of jira also it is showing the same result.

But it is not showing the correct result even though story with same fix version exists in jira.

@krishnashah,

I think you have the quotes in the wrong place: "2.0 & Good" tells Jira you want a single fix version named 2.0 & Good. I think what you want would be "2.0" & "Good" to indicate you want the intersection of 2.0 and Good.

To search for an issue that is a Bug and the fixVersion field contains the values 2.0 and Good, then the query would be:

issuetype = Bug AND (fixVersion = "Good" AND fixVersion = "2.0")

or:

issuetype = Bug AND fixVersion = "Good" AND fixVersion = "2.0"

Do a Google search for Jira JQL queries to understand how the JQL language works and how to construct queries using the and keyword.

Hi @krishnashah ,

If you want to filter a field by multiple values, you might want to try the IN operator. In your case, with the understanding that you are looking for fixVersion 1.0 and 2.0, it will be something like fixVersion IN (1.0, 2.0).

For JQL reference, this documentation will be very handy as it shows the supported operators and functions.

Hope this helps!
Ian

1 Like

Hello @iragudo

Please double-check the answer you have given. The OP asked how to find when a field contained two values at the same time (AND), not when the field contained either value (OR).

Using IN (1.0, 2.0) would be same as:

issuetype = Bug AND fixVersion = "1.0" OR fixVersion = "2.0"

…which is not what the OP needs.

Refer to this IN operator documentation for more detail.

1 Like

Thanks, @sunnyape ! Yes, you are right, as the OP’s example was an AND and I provided an OR. Thanks for correcting me.