Solved: Creating customfield options using REST API for Jira 10

Hi,

Posting this since we struggled with getting this going on Jira 10.
On Jira 9 (and older) we created a bunch of testdata including customfields with options.

From Jira 10 this no longer worked. It all boiled done to the breaking changes as listed here: https://developer.atlassian.com/server/jira/platform/jsw-10-jsm-6-all-breaking-changes/
and specifically this:

Private endpoint POST globalconfig/1/customfieldoptions/{customFieldId}/ provided by com.atlassian.jira.projectconfig.rest.global.CustomFieldOptionsResource#setOptions removed

Use POST globalconfig/1/customfieldoptions/{customFieldId}/setOptions provided by com.atlassian.jira.projectconfig.rest.global.CustomFieldOptionsResource#setOptionsForCustomField instead.

The problem was that not only did the endpoint change but the format of its payload.
So where we used to pass the options as:

[
  {"id": 10000, "name": "A"},
  {"id": 10001, "name": "B"},
  {"id": 10002, "name": "C"}
]

we now have to pass it in the following format:

{"options": [
  {"id": 10000, "name": "A"},
  {"id": 10001, "name": "B"},
  {"id": 10002, "name": "C"}
]}

Have not found any documentation about this, but stumbled over a reply in an old discussion here: Create multi-select custom field with options usin...

Thanks,
Fredrik