Going Stellar

Home/Jira fields reference

Jira Cloud fields and work types

Jira read-only text custom field: what the API allows

The read-only text field is meant to be filled by an app or automation, not by people on the screen. The API still accepted a plain string for it and stored it. The field is searched like other text fields.

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.
POST/rest/api/3/search/jqlFinds work items by value.

Examples

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

Writes a string to the field and the response shows it stored.

curl

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

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

Response: HTTP 200

{
 "key": "ZZREF-6",
 "fields": {
  "customfield_10181": "cannot set"
 }
}

Sent to Atlassian Cloud on .

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

Reading returns the string.

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_10181": "cannot set"
 }
}

Sent to Atlassian Cloud on .

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

Edit metadata lists the field as editable with the operation set.

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_10181": {
   "name": "zz-ref readonly",
   "operations": [
    "set"
   ]
  }
 }
}

Sent to Atlassian Cloud on .

POST /rest/api/3/search/jql

Finds work items where the field has no value.

curl

curl -X POST \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  --data '{
  "jql": "project = ZZREF AND \"zz-ref readonly\" is EMPTY",
  "fields": [
    "summary"
  ],
  "maxResults": 2
}' \
  'https://your-domain.atlassian.net/rest/api/3/search/jql'

Python (requests)

import os
import requests

EMAIL = "you@example.com"
r = requests.post(
    'https://your-domain.atlassian.net/rest/api/3/search/jql',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
    json={'jql': 'project = ZZREF AND "zz-ref readonly" is EMPTY',
          'fields': ['summary'],
          'maxResults': 2},
)
print(r.status_code, r.text)

Response: HTTP 200

{
 "issues": [
  {
   "key": "ZZREF-10"
  },
  {
   "key": "ZZREF-9"
  }
 ],
 "isLast": false
}

Sent to Atlassian Cloud on .

How it behaves

  • Type key com.atlassian.jira.plugin.system.customfieldtypes:readonlyfield, searcher key com.atlassian.jira.plugin.system.customfieldtypes:textsearcher, schema type string, display name "Text Field (read only)".
  • "cannot set" answered 200 and the field read back as "cannot set", so the REST edit is not blocked for this type.
  • Edit metadata lists the field with the operation set.
  • "zz-ref readonly" is EMPTY returned work items without a value.

Pitfalls

  • Read only describes the screen behaviour, not an API restriction, so do not use the type to protect values from API clients.
  • The edit operation does not check screen configuration, so a field absent from the screen can still be written by id.
  • Permissions on the work item, such as Edit issues, still apply to the request.

Questions and answers

Can the API write a read-only text field?

In the run it could: the string was accepted with 200 and stored.

Sources

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

Markdown version · All Jira fields pages