How to query multiple words in JQL via API

Ritong Chen May 5, 2019

I am working on text search(against all fields) with Jira API. One word works well. For example:

http://localhost:8888/rest/api/2/search?jql=text~Clinic

However how to query with multiple words, like

http://localhost:8888/rest/api/2/search?jql=text~Clinic Trial

I am trying to use AND 

http://localhost:8888/rest/api/2/search?jql=text~"Clinic AND Trial"

Neither works.

Any suggestion?

Thanks!

 

 

 

 

2 answers

1 vote
Kurt Klinner
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.
May 5, 2019
 
Craig ist absolutely right, whitespaces in URLs need to be encoded accordingly
0 votes
Craig Castle-Mead
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.
May 5, 2019

Hey Ritong,

How about the below approach?

text ~ ‘clinic’ and text ~ ‘trial’

 

CCM

Ritong Chen May 5, 2019

No it does not work. Here is my command

 

curl -D- -u username:password -X GET -H "Content-Type: application/json" http://localhost:8888/rest/api/2/search?jql=text~'Clinic' and text~'Trial'

It executed the first part but threw error in the second part

curl: (6) Could not resolve host: and
curl: (6) Could not resolve host: text~'Trial'

Kurt Klinner
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.
May 5, 2019

@Ritong Chen 

 

Hi Ritong

curl interprets parts of your query 

Can you try

 

curl -D- -u username:password -X GET -H "Content-Type: application/json" "http://localhost:8888/rest/api/2/search?jql=text~'Clinic' and text~'Trial'"

 

so double quotes around the whole url to ensure that curl takes that as one argument

 

Cheers

Kurt

Ritong Chen May 5, 2019

I tried a similar thing but the API did not like it. The Java code throw similar 400 error as well.

 

curl -D- -u username:password -X GET -H "Content-Type: application/json" "http://localhost:8888/rest/api/2/search?jql=text~'Clinic' and text~'Trial'"
HTTP/1.1 400
Transfer-Encoding: chunked
Date: Mon, 06 May 2019 02:08:59 GMT
Connection: close

Craig Castle-Mead
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.
May 5, 2019

How about the below:

 

http://localhost:8888/rest/api/2/search?jql=text~Clinic%20and%20text~Trial

That doesn’t error on my environment at least. 

CCM

Like # people like this
Ritong Chen May 6, 2019

perfect! Thank you so much Craig.

Craig Castle-Mead
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.
May 7, 2019

Hey @Ritong Chen  - glad you got it working!

 

CCM

thomas.schneider
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 3, 2021

thanks folk! Running great.

Query getting two custom fields for all undone issues from a  specific project.

 

"/rest/api/3/search?jql=project=ABC%20and%20statusCategory!=Done&fields=status,customfield_1111,customfield_1112&startAt=0"

Suggest an answer

Log in or Sign up to answer