jql AND multiple labels

Mike Hedblom February 19, 2019

In a jql query, how do you do an AND on two different labels?

In the Advance Search in the UI, I can use this expression and get 10 results:

labels = v6 AND labels = TestLabel

But when I use this jql query and curl, I get zero results; no errors, no issues:

--data '{"jql":"labels = v6 AND labels = TestLabel"}'
...
{"startAt":0,"maxResults":50,"total":0,"issues":[]}

In the jql query, I can do either label and get 50 of results (maxResults).

How do you do the AND in jql?

4 answers

1 accepted

0 votes
Answer accepted
Mike Hedblom February 20, 2019

Actually, I am beginning to suspect it is a permissions issue, and am trying to confirm. The account I use for API access is supposed to be identical to my login, but it is different. And though the API call is seeing the maxRecord 50 results for each label, I am not finding any that actually have both labels. (Stupid permissions issues will get you every time.) I'll post an update when I know for sure.

Mike Hedblom February 25, 2019

User error. The API account did not have access to the projects that had both labels. it did have access to projects that one or the other label, which is what caused my confusion.  Thanks all who made suggestions!

Like Marty likes this
Marty
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 25, 2019

I'm glad you got to the bottom of it!

0 votes
Marty
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 20, 2019

Hi Mike,

what you're seeing says to me that the problem is not with the jql search you're using but with the way it is being sent using cURL.  

Can you confirm that you are sending a POST?

Are you adding a Content-Type header?

Hopefully we can get you unblocked.

Marty
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 20, 2019

I'd recommend looking at some of these examples

https://gist.github.com/subfuzion/08c5d85437d5d4f00e58

0 votes
Mike Hedblom February 20, 2019

This one also returns no results

{"jql":"labels in (v6) and labels in (TestLabel)"}

Again, I can do either label individually and get maxResult results.

0 votes
KellyW
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 19, 2019

Hi Mike,

Try the cURL command with the JQL append to the URL, e.g:

curl -D- -X GET -H "Authorization: Basic encoded" -H "Content-Type: application/json" https://<base_url>/rest/api/2/search?jql=labels = v6 and labels = TestLabel

Mike Hedblom February 20, 2019

Same: no results.  Thanks for trying!

Marty
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 20, 2019

You could try this with the url encoded

eg.

https://<base_url>/rest/api/2/search?jql=labels%20%3D%20v6%20and%20labels%20%3D%20TestLabel

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events