Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to get list of all Jira server fields (system and custom) via REST-API

Use curl in a Linux Bash script:

#!/bin/bash

admin_user=fu
admin_password=bar
jira_server="https://jira.acme.com"
api_version=2
url_part2="/rest/api/${api_version}/field"

curl -k -u ${admin_user}:${admin_password} -X GET -H "Accept: application/json" ${jira_server}${url_part2} \
| jq '.' > raw_file.json

# Extract field names, remove double quotes, sort

cat raw_file.json | jq '.[].name' | sed 's/"//g' | sort > nice_file.txt

 

Note: There is a separate REST-API to get only custom fields, but it's not working for me at this time. I will update once I find a solution.

Updates

1. The REST-API for Jira Server does not support getting only the custom fields.

Your recourse is to check the "id" key in the JSON (the file raw_file.json). If the value is "customfield_nnnnn", it's a custom field. Or, even simpler, you can check the key "custom" which is "true" for custom fields.

2. When you view the fields in the Jira UI

    https://jira.acme.com/secure/admin/ViewCustomFields.jspa

there may be fields which are marked Not configured for any context under the Available context(s) column.

I've found out that the REST-API call does not retrieve these fields.

1 comment

Suddha Atlassian Team Sep 29, 2020

Recently came across this requirement and taking hint from this script, was able to extract just the custom fields:

Hope that helps:

#!/bin/bash
# small script to CSV export Custom Fields
# Author: Mr. Doubt Everyhim
# Date: 2020-09-22
#
#
#
admin_user=foo
admin_password=bar
jira_server="http://localhost:8854/j854"
url_part2="/rest/api/2/field"

# Get all the fields:
curl -k -u ${admin_user}:${admin_password} -X GET -H "Accept: application/json" ${jira_server}${url_part2} \
 | jq '.' > raw_file.json
# Create to_entries:
cat raw_file.json| jq 'to_entries' > raw_key_entry.json
# Extract keys:
cat raw_key_entry.json | grep -B2 customfield_ | grep key | awk '{print $2}' | sed 's/,//g' > key_entries.txt 
# Extract ID, Name, Field Types:
for i in $(cat key_entries.txt); do
  cat raw_file.json | jq -r "[.[$i].id, .[$i].name, .[$i].schema.custom] |@csv" >> CF_details.csv
done
echo "Results are printed in: ./CF_details.csv"
Like Amir Katz _Outseer_ likes this

Comment

Log in or Sign up to comment
TAGS
Community showcase
Published in Jira

Admins, notify your Jira instance of system-wide changes with the new admin announcement banner

Hi All! We’re excited to share the launch of an announcement banner that lets Jira site administrators communicate directly to their users across their  Jira Cloud instance.  ...

637 views 16 18
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you