Going Stellar

Home/Jira fields reference

Jira Cloud fields and work types

Jira fixVersions field: set versions by name

fixVersions holds the versions in which a work item is fixed, as an array of version objects. It is written with names such as {"name": "1.0"} and read back with self, id, name, archived and released. The JQL name is fixVersion, singular.

Endpoints

MethodPathWhat it does
PUT/rest/api/3/issue/{issueIdOrKey}Sets fields.fixVersions with version names.
GET/rest/api/3/issue/{issueIdOrKey}Returns fixVersions as an array of version objects.
GET/rest/api/3/fieldLists the field and its JQL name.

Examples

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

Sets one release by name and reads the field back.

curl

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

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=fixVersions',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
    params={'returnIssue': 'true', 'fields': 'fixVersions'},
    json={'fields': {'fixVersions': [{'name': 'zz-ref 1.0'}]}},
)
print(r.status_code, r.text)

Response: HTTP 200

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

Sent to Atlassian Cloud on .

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

Reads fixVersions with other system fields.

curl

curl -G \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  --data-urlencode 'fields=priority,duedate,labels,components,fixVersions,environment,timetracking,reporter,status,resolution,issuetype,project,created,updated' \
  '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': 'priority,duedate,labels,components,fixVersions,environment,timetracking,reporter,status,resolution,issuetype,project,created,updated'},
)
print(r.status_code, r.text)

Response: HTTP 200

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

Sent to Atlassian Cloud on .

GET /rest/api/3/field

The third entry in the field list is fixVersions, with the JQL name fixVersion and an array of version schema.

curl

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

Python (requests)

import os
import requests

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

Response: HTTP 200

[
 {
  "id": "statuscategorychangedate",
  "name": "Status category changed",
  "clauseNames": [
   "statusCategoryChangedDate"
  ],
  "schema": {
   "type": "datetime",
   "system": "statuscategorychangedate"
  }
 },
 {
  "id": "customfield_10076",
  "name": "Incident manager",
  "clauseNames": [
   "Incident manager[User Picker (single user)]",
   "Incident manager",
   "cf[10076]"
  ],
  "schema": {
   "type": "user",
   "custom": "com.atlassian.jira.plugin.system.customfieldtypes:userpicker",
   "customId": 10076
  }
 },
 {
  "id": "fixVersions",
  "name": "Fix versions",
  "clauseNames": [
   "fixVersion"
  ],
  "schema": {
   "type": "array",
   "items": "version",
   "system": "fixVersions"
  }
 }
]

Sent to Atlassian Cloud on .

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

Sets a version name that does not exist.

curl

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

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=fixVersions',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
    params={'returnIssue': 'true', 'fields': 'fixVersions'},
    json={'fields': {'fixVersions': [{'name': '9.9'}]}},
)
print(r.status_code, r.text)

Response: HTTP 400

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

Sent to Atlassian Cloud on .

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

A multi-version picker custom field takes the same objects and reads back with the same properties.

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 .

How it behaves

  • {"fixVersions": [{"name": "zz-ref 1.0"}]} answered 200 and returned self, id, name, archived false and released false (sys-fixversions).
  • The field list gives fixVersions the schema type array of version and the single JQL name fixVersion (fields-all).
  • The multi-version custom field accepted two names and returned both objects in one array (set-multiversion).
  • An unknown name answered 400 with Version name '9.9' is not valid, unlike components (sys-fixversions-bad).

Pitfalls

  • The JQL name is fixVersion even though the field id is fixVersions.
  • The version must already exist in the project. An unknown name is refused, so create it first.
  • As with components, the field is absent from the edit metadata of the test work item although the write worked, so absence there is not proof it cannot be set.

Questions and answers

How do I remove all fix versions?

Setting an empty array was not run for this page. Send fixVersions as [] on a test item and check the response.

What does released mean in the response?

It is a property of the version object, false for an unreleased version.

Sources

  1. Issues (Jira REST API v3)
  2. Edit issue (Jira REST API v3)
  3. Get issue (Jira REST API v3)
  4. Get fields (Jira REST API v3)

Markdown version · All Jira fields pages