api/2/field create multiselect field

Artemy Matvienko
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 7, 2017

I'm trying to create a new multiselect field using the REST api/2/field POST endpoint. I would like to populate the options of this multiselect as part of the request. I can't find any info on whether its possible to populate those options and, if it is possible, what the JSON object property is called and what key-value pairs I should be using. Here's the PHP & cURL request data/body I have tried:

$data = array(
"name" => "Test Customer List",
"description" => "Custom test field for picking customers",
"type" => "com.atlassian.jira.plugin.system.customfieldtypes:multiselect",
"searcherKey" => "com.atlassian.jira.plugin.system.customfieldtypes:multiselectsearcher",
"options" => array(
"value" => "test1",
"value" => "test2",
"value" => "test3",
),
);
$data = json_encode($data);

 Here's the error I'm getting in the response:

[errorMessages] => Array
(
[0] => Unrecognized field "options" (Class com.atlassian.jira.rest.api.customfield.CustomFieldDefinitionJsonBean), not marked as ignorable
at [Source: org.apache.catalina.connector.CoyoteInputStream@3ddbcd03; line: 1, column: 254] (through reference chain: com.atlassian.jira.rest.api.customfield.CustomFieldDefinitionJsonBean["options"])
)

If there is no way to set the options using this endpoint, what would be the alternative for populating this field programmatically upon or after creation?

1 answer

1 accepted

0 votes
Answer accepted
Alexey Matveev
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 7, 2017

Hello,

It is not possible for Jira Server, but for Jira Cloud you can use api/2/field/{fieldKey}/option

https://docs.atlassian.com/software/jira/docs/api/REST/1000.1568.0/#api/2/field/{fieldKey}/option

Suggest an answer

Log in or Sign up to answer