Going Stellar

Home/Jira fields reference

Jira Cloud fields and work types

Jira multi version picker custom field: set via API

The multiple versions picker takes an array of {"name": ...} objects and returns an array of version objects. Edit metadata allows set, add and remove.

Endpoints

MethodPathWhat it does
PUT/rest/api/3/issue/{issueIdOrKey}Sets or changes the value.
GET/rest/api/3/issue/{issueIdOrKey}Reads the stored value.
GET/rest/api/3/issue/{issueIdOrKey}/editmetaLists what can be edited.

Examples

PUT /rest/api/3/issue/{issueIdOrKey}

Sets two versions by name.

curl

curl -X PUT \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  --data '{
  "fields": {
    "customfield_10180": [
      {
        "name": "zz-ref 1.0"
      },
      {
        "name": "zz-ref 2.0"
      }
    ]
  }
}' \
  'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}?returnIssue=true&fields=customfield_10180'

Python (requests)

import os
import requests

EMAIL = "you@example.com"
r = requests.put(
    'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}?returnIssue=true&fields=customfield_10180',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
    params={'returnIssue': 'true', 'fields': 'customfield_10180'},
    json={'fields': {'customfield_10180': [{'name': 'zz-ref 1.0'}, {'name': 'zz-ref 2.0'}]}},
)
print(r.status_code, r.text)

Response: HTTP 200

{
 "key": "ZZREF-6",
 "fields": {
  "customfield_10180": [
   {
    "self": "https://your-domain.atlassian.net/rest/api/3/version/10002",
    "id": "10002",
    "name": "zz-ref 1.0",
    "archived": false,
    "released": false
   },
   {
    "self": "https://your-domain.atlassian.net/rest/api/3/version/10003",
    "id": "10003",
    "name": "zz-ref 2.0",
    "archived": false,
    "released": false
   }
  ]
 }
}

Sent to Atlassian Cloud on .

PUT /rest/api/3/issue/{issueIdOrKey}

An unknown version name in the array is refused.

curl

curl -X PUT \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  --data '{
  "fields": {
    "customfield_10200": [
      {
        "name": "9.9"
      }
    ]
  }
}' \
  'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}?returnIssue=true&fields=customfield_10200'

Python (requests)

import os
import requests

EMAIL = "you@example.com"
r = requests.put(
    'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}?returnIssue=true&fields=customfield_10200',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
    params={'returnIssue': 'true', 'fields': 'customfield_10200'},
    json={'fields': {'customfield_10200': [{'name': '9.9'}]}},
)
print(r.status_code, r.text)

Response: HTTP 400

{
 "errorMessages": [],
 "errors": {
  "customfield_10200": "Version name '9.9' is not valid"
 }
}

Sent to Atlassian Cloud on .

GET /rest/api/3/issue/{issueIdOrKey}

Reading returns the two version objects.

curl

curl -G \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  --data-urlencode 'fields=customfield_10162,customfield_10163,customfield_10164,customfield_10165,customfield_10166,customfield_10167,customfield_10168,customfield_10169,customfield_10170,customfield_10171,customfield_10172,customfield_10173,customfield_10174,customfield_10175,customfield_10176,customfield_10177,customfield_10178,customfield_10179,customfield_10180,customfield_10181' \
  'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}'

Python (requests)

import os
import requests

EMAIL = "you@example.com"
r = requests.get(
    'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
    params={'fields': 'customfield_10162,customfield_10163,customfield_10164,customfield_10165,customfield_10166,customfield_10167,customfield_10168,customfield_10169,customfield_10170,customfield_10171,customfield_10172,customfield_10173,customfield_10174,customfield_10175,customfield_10176,customfield_10177,customfield_10178,customfield_10179,customfield_10180,customfield_10181'},
)
print(r.status_code, r.text)

Response: HTTP 200

{
 "key": "ZZREF-6",
 "fields": {
  "customfield_10180": [
   {
    "self": "https://your-domain.atlassian.net/rest/api/3/version/10002",
    "id": "10002",
    "name": "zz-ref 1.0",
    "archived": false,
    "released": false
   },
   {
    "self": "https://your-domain.atlassian.net/rest/api/3/version/10003",
    "id": "10003",
    "name": "zz-ref 2.0",
    "archived": false,
    "released": false
   }
  ]
 }
}

Sent to Atlassian Cloud on .

GET /rest/api/3/issue/{issueIdOrKey}/editmeta

Edit metadata lists the three operations and the versions that can be chosen.

curl

curl \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}/editmeta'

Python (requests)

import os
import requests

EMAIL = "you@example.com"
r = requests.get(
    'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}/editmeta',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
)
print(r.status_code, r.text)

Response: HTTP 200

{
 "fields": {
  "customfield_10180": {
   "name": "zz-ref multiversion",
   "operations": [
    "set",
    "add",
    "remove"
   ],
   "allowedValues": [
    {
     "id": "10002",
     "name": "zz-ref 1.0"
    },
    {
     "id": "10003",
     "name": "zz-ref 2.0"
    }
   ]
  }
 }
}

Sent to Atlassian Cloud on .

How it behaves

  • Type key com.atlassian.jira.plugin.system.customfieldtypes:multiversion, searcher key com.atlassian.jira.plugin.system.customfieldtypes:versionsearcher, schema type array with items version, display name "Version Picker (multiple versions)".
  • [{"name": "zz-ref 1.0"}, {"name": "zz-ref 2.0"}] answered 200 and read back as two version objects.
  • [{"name": "9.9"}] gave 400 "Version name '9.9' is not valid", worded differently from the single version picker.
  • Edit metadata lists operations set, add and remove, in that order.

Pitfalls

  • The system fixVersions field is a different field and has its own page.
  • Setting with fields replaces the list; use update to change one version.
  • The two version pickers word the unknown-name error differently, so match on the status and the key.

Questions and answers

Which operations are available?

Set, add and remove, according to edit metadata.

Sources

  1. Issues (Jira REST API v3)
  2. Issue fields (Jira REST API v3)

Markdown version · All Jira fields pages