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?
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.
Thanks, I also can get the id of the options via this url
/rest/api/2/field/{customFieldId}/option
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.