JIRA and JQL: How can I filter results where custom fields are not empty?

Viewed 205

I'm working on a get request that gives me all JIRA issues with the custom field "Sponsor". Since it's an optional field, the value is often empty. So out of all issues in a JIRA project, how can I extract those who have a sponsor? My query looks like this so far

https://jira.companyname.com/rest/api/2/search?jql=project=projectname&maxResults=1000

What is missing? I do know the customField name and id.

I tried

jql=project=projectname&maxResults=1000&customfield_number!%3DEMPTY

and

jql=project=projectname&maxResults=1000&customfield_number!%3Dnull

But it didn't work

2 Answers

Try is not EMPTY in your JQL query, rather than != null or !=EMPTY.

Substitute number for your custom field number and try this request URL: https://jira.companyname.com/rest/api/latest/search?jql=cf%5Bnumber%5D%20is%20not%20EMPTY

I finally figured it out thanks to someone who helped me in another forum. The problem was that I treated the customfield parameter not as one in the jql query... So Adil's answer was correct, my problem was that I put cf%5Bnumber%5D%20is%20not%20EMPTYin the final part of the query. after maxResults.

Final URL that works for me looks like this:

https://jira.companyname.com/rest/api/2/search?jql=project=key+and+cf[id]+is+not+empty&maxResults=1000
Related