Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Create multi-select custom field with options using rest-api in jira server 8.4

Fayaz Abdul
Contributor
October 3, 2019

Hello,

 

I am trying to create a multi-select custom field with options like test1,test2,test3 using rest-API in Jira server 8.4.

Using https://jira.com/rest/api/2/field 

raw(JSON)

{   "name""ReTest field",

    "description""Custom field for testing",   

    "type""com.atlassian.jira.plugin.system.customfieldtypes:multiselect",   

    "searcherKey""com.atlassian.jira.plugin.system.customfieldtypes:multiselectsearcher"

}

But there is no options in it.

Please help me to create with options using rest api.

Thank you

Fayaz

2 answers

1 vote
Surya U N
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 21, 2020

Not sure if this would help you now. Might help someone else!

There's a work-around that solved this issue.

1) Create the custom field using POST /rest/api/2/field and body json as you do.

2) After the custom field is created (it'll be created without options), you can POST to /rest/globalconfig/1/customfieldoptions/{custom_field_id} with the body json as below:

[{"name":"option1"}, {"name":"option2"}]
john_cougar
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 23, 2024 edited

Hi Surya, this was helpful but didn't actually work on the later versions of Data Center, due to a missing tag. You need to prefix the body JSON options list with a literal "options" tag, viz:

"options":[{"name","option1"}, {"name", "option2"}, ...]

It took me a lot of searching to find this, and the idea of adding the tag sprang from someone's implementation of this against the new version of Cloud REST API. But I can confirm that it works on Data Center.

Also note that you must append "setOptions" to the URL command. Viz:

rest/globalconfig/1/customfieldoptions/{custom field id}/setOptions

So the curl command to set the options of an existing custom select field would go like this:

curl -D- -u "<username:pwd>" -X POST -H "Content-Type: application/json" -H "X-Atlassian-Token: nocheck" http://<your_host_baseurl>/rest/globalconfig/1/customfieldoptions/{customfield_nnn}/setOptions?os_AuthType=basic -d '{"options":[{"name":"option1"},{"name":"option2"}]}'

 

Like freatt likes this
freatt January 23, 2025

Hi @john_cougar

Thanks for posting this update!

When Jira 10 was released, this broke our test generation and now I finally stumbled over your update which got things working again!

Thanks,

Fredrik

 

0 votes
Elifcan Cakmak
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.
October 3, 2019

Hello,

I think that's not possible at the moment. I found this related ticket about the issue:

https://jira.atlassian.com/browse/JRASERVER-36112

It's still in gathering interest status. Although you can check out plugins for this issue like:

https://marketplace.atlassian.com/apps/1217643/extender-for-jira?hosting=server&tab=overview

Regards.

Elifcan

john_cougar
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 23, 2024

Hi Elifcan, It is possible, I have just tested it on Data Center, and there is a fair bit of stuff like this for Cloud. I confess it did take some digging, and I was almost discouraged by the claim that using the path:

/rest/globalconfig/1/customfieldoptions/{custom_field_id}/setOptions 

... is unsupported, but it does work for me. I'm still checking to see if there's a way to ADD additional options without wiping out the original ones but getting closer!

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, jira service management, jsm webinar, ai in jsm, opsgenie integration, incident management, virtual agent, atlassian intelligence, ai-powered service desk, it operations, atlassian learning, service management webinar, team '25 recap

What’s new in Jira Service Management 🤔

Discover how Atlassian is revolutionizing service management with cutting-edge solutions for AI-powered support, HR Service Management, or DevOps connectivity.

Register here ⬇️
AUG Leaders

Atlassian Community Events