I am unable to search using custom field.

Jagjeet Randhawa December 28, 2015

Here is the API I am using

https://company.atlassian.net/rest/api/2/search?jql=project=UWS&customfield_10803=abcd&maxResults=2&fields='assignee,status,resolution'

The API returns the latest tickets for that project not taking into account the value of the custom field value specified in the API.

4 answers

1 vote
joachimbollen
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.
December 28, 2015

You'll need to make a correct JQL statement to include the custom field like

https://company.atlassian.net/rest/api/2/search?jql=project%3DUWS%20AND%20customfield_10803%3Dabcd&maxResults=2&fields='assignee,status,resolution'

 

So concatenating the search parameters to a string and url-encoding it instead of adding another field to the request.

0 votes
Sam Huawey December 28, 2015

What I usually do with REST search is first I try to put the JQL into the Advanced search in JIRA. As Joachim mentioned, your JQL is incorrect - it only searches for all of the issues in project UWS. What you really need is something like this:

project=UWS AND customfield_10803=abcd

If you enter this string in advanced searching, you will also have a chance to check the syntax. The '=' operator works with selections only, if your custom field contains text, you need to use '~'.

 

Jagjeet Randhawa December 29, 2015

I already tried this before posting the question here :) However it gives me an error response saying"Field 'customfield_10803' does not exist or you do not have permission to view it." But I know that this field exists because this is in the response when I try using https://company.atlassian.net/rest/api/2/field . Part of Response: {"id":"customfield_10803","name":"Impacted Client(s)","custom":true,"orderable":true,"navigable":true,"searchable":true,"clauseNames":["cf[10803]","Impacted Client(s)"],"schema":{"type":"array","items":"option","custom":"com.atlassian.jira.plugin.system.customfieldtypes:multiselect","customId":10803}},

GabrielleJ
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.
December 29, 2015

As said, use the NAME not the ID

0 votes
GabrielleJ
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.
December 28, 2015

Are you actually using the "Custom Field Name" name instead of the "Custom Field ID"? If not, can you try that?

0 votes
Jobin Kuruvilla [Adaptavist]
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.
December 28, 2015

What happens when you search using the same JQL in JIRA directly?

Suggest an answer

Log in or Sign up to answer