Adding/Appending Custom Field Options via API

Hi,

I’m unfortunately stuck with an internal task and need a hint/advice.

I get a Trigger from an External System. Each time that trigger arrives, I want to Append a new Option to a custom field in Jira.

As the process should be really simple with the API, I did not create an App yet but followed the Basic Auth way. I followed the authentication Basic auth for REST APIs and I can make a GET for all fields.

The field I want to append my options to has the id:
customfield_11180

Based on the information from this page Deprecation Notice: deprecation of custom field options APIs (+new APIs published) I thought about using this GET /rest/api/3/field/{fieldId}/context/{contextId}/option but I have no clue what the context is or where to find it.

I tried using this /rest/api/2/field/{fieldId}/context but this endpoint seems to require a connected app.

Is there any way to append options via the normal REST basic Auth way or do I have to Register/Build an app?

Any help is very much appreciated :bowing_man: .

Thank you very much and have a great day.

BR
Benji

Welcome to the Atlassian Developer Community, @BenjaminExner!

Yes, this can be done using basic authentication given you have the necessary permission. Let’s start at the part where you got stuck.

  1. To find the contextId of a custom field, you can use Get custom field context API. In the response, the values will contain an array of CustomFieldContext, use the id of the intended context. The response will look something like this (I only have one context for the custom field)
{
    "maxResults": 50,
    "startAt": 0,
    "total": 1,
    "isLast": true,
    "values":
    [
        {
            "id": "10208",
            "name": "Default Configuration Scheme for Ian Stock Multi-Select",
            "description": "Default configuration scheme generated by Jira",
            "isGlobalContext": true,
            "isAnyIssueType": true
        }
    ]
}
  1. Use id from number 1 as the contextId when calling Create custom field options. For the request body parameter, you can use something like
{
  "options": [
    {
      "disabled": false,
      "value": "bar"
    },
    {
      "disabled": false,
      "value": "baz"
    }
  ]
}

Let me know how it goes.

Ian

EDIT:

Does your account have Administer Jira permissions? I tried this endpoint using curl just now and it returned the expected response.

Hi @iragudo ,

thank you and yes I have Administrator rights, that was also the reason why I was surprised.

I tried the Endpoints and it worked perfectly I was able to already test the workflow and automatically create the first options.

Thank you very much for the fast help :bowing_man:

BR
Benji

1 Like

You’re welcome, Benji. Glad you were able to make it work.