Background
In our Jira Cloud, we have > 1600 custom fields (don't ask why...). I took upon myself to perform a cleanup of the CFs. I am a Jira admin, of course.
A CF can be deleted if all the below conditions are met:
- It is not a LOCKED field
- It is not included in any screens
- Its Last Used date is empty
- It does not appear in any issue
Items 1-3 can be viewed in the Jira UI when you go to Settings --> Issue --> Custom Fields and search for your CF by name.
Condition #4 is not readily visible and it requires you to perform a simple JQL search:
"<field-name>" is NOT EMPTY
This is assuming that the field name is unique, which may not be the case, but that's another story...
Problem
The problem that I see that for many CFs, the above search returns an error:
Field 'enVision RCA Fault Code' does not exist or you do not have permission to view it.
When I perform this search with the Jira REST API, using the field ID, the REST API returns 400 ("bad request").
The above field is a single choice select list, so the query is definitely valid.
I know for a fact that this field is not in a team-managed project.
The REST API call payload (for this CF) is {"jql": "cf[11335] is not EMPTY"}
The REST API documentation says that 400 means 'Returned if the JQL query is invalid.'
I get this error for many, many CFs, so I wonder if I'm doing anything wrong.
Thanks.
References
REST API: https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-search/#api-rest-api-3-search-get