Forums

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

Jira REST API - Unable to combine elements in the query

Sandor Kocsis August 13, 2019

Hi everyone,

 

I'm unable to build a query which gives me results to a certain (HR) project only. If I send this query to the API:

rest/api/2/search?jql=summary~"SUMMARY"&fields=id,key

 

Then I receive tickets for multiple projects, so I'm trying to add the project=HR as a filter, but the queries I've built so far do not provide me with the expected results and HRS related tickets are also part of the output.

What I'm receiving now is:

Annotation 2019-08-13 101320.png

Can someone help?

2 answers

1 accepted

0 votes
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.
August 13, 2019

Hi @Sandor Kocsis 

This

rest/api/2/search?jql=project=HR AND summary~"SUMMARY"&fields=id,key

should work, if your project key is HR.

If it doesn't work, try project=HR AND summary~"SUMMARY" in the Jira query filter, which will tell you if the jql part is working. For example I get 

Screenshot_1.jpg

because the project HR doesn't exist in my Jira instance.

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.
August 13, 2019

I've just enlarged your screenshot and noticed you're getting issues from HR and HRS.

Again in the Jira query filter box, if you start typing project=hum it should show the two projects and you need to use the full project name, not the key. So it would be project="Human Resources" or whatever the full project name is.

0 votes
Sandor Kocsis August 13, 2019

Hi guys,

 

I tested this one and it works:

/rest/api/2/search?jql=project=HR%20AND%20summary~"SUMMARY"&fields=key

 

It works with or without using "%20" for replacing whitespaces in the query, what is the recommended way of replacing whitespaces?

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.
August 13, 2019

I don't replace them at all, I've always just left the spaces there without a problem, but as you say, the %20 should also work, just more difficult to read

Sandor Kocsis August 13, 2019

alright, thanks for your help on this, Warren!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events