Forums

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

how to pick a value from a multi value custom field when creating an issue via api rest

Héctor García October 12, 2021

i'm creating issues using api rest using  https://todo1jira.atlassian.net/rest/api/latest/issue/

this one works perfect

=========================================================

curl -i --location --request POST "https://todo1jira.atlassian.net/rest/api/latest/issue/" --header "X-Atlassian-Token: no-check" --header "Accept: application/json" --header "Authorization: Basic XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX=" --header "Content-Type: application/json" --data-raw "{""fields"": { ""project"": { ""key"": ""xxxxx"" }, ""customfield_23797"": ""890918159"", ""customfield_23468"": ""2021-07-01"", ""customfield_23469"": ""2021-07-31"", ""summary"": ""este ticket lo estoy creando como el viejo cami"", ""issuetype"": { ""id"": ""xxxxxxx"" } }}"

=========================================================

 

but when the custom field is a multi value I'm not getting the way to do it 

 

for example I have a custom field 10304 and need to pick "DRC" (id 12900)

"customfield_10304": {
"required": true,
"schema": {
"type": "array",
"items": "option",
"custom": "com.atlassian.jira.plugin.system.customfieldtypes:multiselect",
"customId": 10304
},
"name": "Ambiente",
"key": "customfield_10304",
"hasDefaultValue": false,
"operations": [
"add",
"set",
"remove"
],
"allowedValues": [
{
"self": "https://todo1jira.atlassian.net/rest/api/2/customFieldOption/29017",
"value": "Azure o CLoud",
"id": "29017"
},
{
"self": "https://todo1jira.atlassian.net/rest/api/2/customFieldOption/12900",
"value": "DRC",
"id": "12900"
},

 

i'm having this error :
{"errorMessages":[],"errors":{"Ambiente":"Specify the value for Ambiente in an array"}}

 

when I try to create the issue  with:
curl -i --location --request POST "https://todo1jira.atlassian.net/rest/api/latest/issue/" --header "X-Atlassian-Token: no-check" --header "Accept: application/json" --header "Authorization: Basic XXXXXXXXXXXXXXXXXXXX=" --header "Content-Type: application/json" --data-raw "{""fields"": { ""project"": { ""key"": ""XXXXXXXXX"" },""customfield_10041"":{""value"":""Administration""},""customfield_10304"":{""value"":[""DRC""]}, ""summary"": ""este es un tciekt de prueba para creacion automatica"", ""issuetype"": { ""id"": ""18"" }}}"

 

any advise?  thanks

1 answer

1 vote
Mahesh Shinde
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 12, 2021

Hi Hector,

You should use proper syntax for multi value field as in your curl command there is bracket syntax error which require as follows:

"customfield_10008": [ {"value": "red" }, {"value": "blue" }, {"value": "green" }]

Not this way =>  {""value"":[""DRC""]}

Please, refer this document https://developer.atlassian.com/server/jira/platform/jira-rest-api-example-create-issue-7897248/#multiselect

Let us know if it working or not.

Héctor García October 12, 2021

thanks Majesh it worked!!!!

Suggest an answer

Log in or Sign up to answer