Forums

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

How to set a custom field of type single-select?

Felipe Ribeiro August 18, 2021

Hello, I need to update a custom field of type single-select, I'm trying to update the same way I update custom field type text or number, sending the value of the option but I get:

request:

PUT `/rest/api/3/issue/${jiraIssueIdOrKey}

body: { fields: { customfield_10030: 'Near Zero' } }

response:

body:

             errorMessages: [],

            errors: { 'f5a3859-5e02-40b1-b00e-88527518c71b-label': "Can not construct instance of java.lang.Long from String value 'Near zero': not a valid Long value\n" + ' at [Source: N/A; line: -1, column: -1]' }

},

 

Does anyone knows how to update a single-select field via the api?

1 answer

1 accepted

0 votes
Answer accepted
Nic Brough -Adaptavist-
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.
August 18, 2021

Select lists do not hold arbitrary strings, they hold options.  To set one with a REST call, you need to feed it the ID of the option (in your case, you need the ID of the option you have named "Near zero")

Go to Admin -> issues -> custom fields and find the custom field numbered 10030, go into its configuration to find the lists of options, then try hovering the cursor over the links associateed with an option - the url the browser shows you will contain something like ?id=10234 - that's the number you need in your payload.

Felipe Ribeiro August 18, 2021

Thanks, I also can get the id of the options via this url

/rest/api/2/field/{customFieldId}/option

Vladimir Virlan
Contributor
November 8, 2021

For API version 3 it would have to be:

/rest/api/3/field/customfield_nnnnn/context/{contextId}/option/

 

You'll have to figure out nnnnn which is your custom field id and {contextId} which can be found when editing custom field (Add, Edit contexts)

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events