It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Add Custom field value Thru REST API In Issue Update Edited

Hi,

I want to add a New Field Value to Multi-Select in Issue Update thru REST API.  While Passing the New Value to the JIRA Update I am getting an error. I am not sure how to add the new value to Multi-select. Any other suggestions will be helpful.

Input:

{
"fields" : {
"customfield_12354" : [
{
"value" : "New Jira Test Account"
}
],
"project" : {
"id" : "11000",
"key" : "TP"
}
},
"issueIdOrKey" : "86758"
}

 

JIRA Output:

{
"errorMessages": [],
"errors": {
"customfield_12354": "Option value 'New Jira Test Account' is not valid"
}
}

 

Thanks,

Nagendra M

2 answers

1 accepted

1 vote
Answer accepted
Andy Heinzer Atlassian Team Jul 26, 2019

Hi,

If I understand your question here, you are trying to create a new value for a multi-select field, assign that value to a specific Jira issue in a single REST API call.

You can not do this action in a single REST API call.  Which might explain why you are getting this error.  When you edit an issue in Jira via REST, you are only able to select from the current possible values that have been preset for that field.  For multi-select fields, their values have to be defined before any issue in Jira can actually utilize that value.  (The same is not true for the labels type field, but this is not the same kind of field).

The other problem here is that for user created custom fields in Jira Cloud, the REST API currently won't let you edit the field option values.  There are a pair of feature requests for this functionality via REST API in

There is an endpoint that could do this in POST /rest/api/2/field/{fieldKey}/option.  However this endpoint can only be used by connect apps (aka plugins or apps) that create custom fields.  From that document:

Note that this operation cannot be used with the built-in custom fields. It only works with issue fields added by Connect apps, as described above.

So if you're creating a connect app that in turn creates a custom field, then you could use that endpoint to add options to a multi-select type custom field.  However if that custom field is not created by a connect app, there does not appear to be a way to change those options/values via REST at this time.  Instead you would need to do this via the web interface of Jira.

Once those options exist for those fields, then you can use the Edit issue endpoint in PUT /rest/api/2/issue/{issueIdOrKey}.  Which can then set/change the custom field value on that issue from the available options.

I hope this helps.

Andy

Like Amir Katz likes this

Hi @Andy Heinzer ,

first, thanks for the detailed reply.

Two years ago I had to create an app that would create a custom field, so that I could manage the options through the REST API.

Now I'm in the same situation, but after checking the Docs I have found a new group of endpoints that apparently work for custom fields created in Jira (no need to create an app):

https://developer.atlassian.com/cloud/jira/platform/rest/v2/#api-group-Issue-custom-field-options

Is this something new? Or am I missing something?

Thanks!

Like Dario B likes this

Hi @Jordi Fontseca ,

We have added endpoints to:

 

However, the feature requests are still open since we still miss the endpoints to edit/delete custom fields and to delete custom fields options. Keep following them for updates.

I hope this explains.

 

Cheers,
Dario

Hi @Dario B !

I see, thanks for the information!

Btw, I have already started using the GET/PUT/POST methods for the custom field options and it's very useful.

I have only encountered one issue: right now, it seems that it's not possible to add new "cascading options" to existing options (for Cascading Select fields).

So I can create an option with two suboptions like this:

POST /rest/api/3/customField/{fieldId}/option

[{"value":"Option A","cascadingOptions":["Suboption 1","Suboption 2"]}]

 

But later I can NOT add a new suboption to it:

POST /rest/api/3/customField/{fieldId}/option

[{"value":"Option A","cascadingOptions":["Suboption 3"]}]

There is no error, but the request is ignored.

Dario B Atlassian Team Jan 28, 2020

Hi @Jordi Fontseca ,

I believe that after the options are created (sending a POST request), you should send a PUT request to update the field instead of sending another POST request.

However, please notice that sending a PUT request to edit the field options is marked as experimental and, as mentioned:

Experimental features

Features and methods marked as experimental may change without notice. Feedback on experimental functionality is welcome. Report your suggestions and bugs in the ACJIRA project (preferred) or use the Give docs feedback link at the top of this page.

 

Can you kindly test this and let me know if it works?

 

Cheers,
Dario

Thanks @Dario B !

I also tried sending a PUT request.

This works for changing an existing value (for instance, replacing "Suboption 2" with "Suboption 2 Renamed"):

PUT /rest/api/3/customField/{fieldId}/option

[{"value":"Option A","newValue":"Option A Renamed","cascadingOptions":[
    {"value":"Suboption 2","newValue":"Suboption 2 Renamed"}
]}]

But it does not allow adding new values (if I provide a "Suboption 3", it is ignored):

PUT /rest/api/3/customField/{fieldId}/option

[{"value":"Option A","newValue":"Option A","cascadingOptions":[
    {"value":"Suboption 3","newValue":"Suboption 3"}
]}]


I have already submitted this to Atlassian Support and they have raised it as a bug here:

https://ecosystem.atlassian.net/browse/ACJIRA-2058

Hopefully it will be fixed soon

Thanks again for the feedback!

Like Dario B likes this
Dario B Atlassian Team Jan 31, 2020

Hi Jordi, 

You are very welcome and thanks for providing an update on this! 

Have a nice weekend!

 

Dario

Hi,

there is also a Jira cloud App called "External Data for Jira Fields" that allows you to synchronise an external data source into field options of native custom fields.

You could connect a custom field with an external API or with a simple Json file. From then on the options will stay in sync (new values added and missing values disabled) so it always reflects your data source.

Maybe this gets you around creating your own connect-app.

Thomas

 

Disclaimer: I am the product manager of said App.

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you