Going Stellar

Home/Jira fields reference

Jira Cloud fields and work types

Jira paragraph custom field: Atlassian Document via API

The paragraph field (textarea) stores rich text. On the v3 API it is written and read as an Atlassian Document Format object; a plain string is refused. The same value reads as plain text on the v2 path and as HTML under renderedFields.

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/2/issue/{issueIdOrKey}Reads the value as text.
GET/rest/api/3/issue/{issueIdOrKey}/editmetaLists what can be edited.

Examples

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

Writes the field as a document with one paragraph node.

curl

curl -X PUT \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  --data '{
  "fields": {
    "customfield_10163": {
      "type": "doc",
      "version": 1,
      "content": [
        {
          "type": "paragraph",
          "content": [
            {
              "type": "text",
              "text": "Paragraph written as ADF."
            }
          ]
        }
      ]
    }
  }
}' \
  'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}?returnIssue=true&fields=customfield_10163'

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_10163',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
    params={'returnIssue': 'true', 'fields': 'customfield_10163'},
    json={'fields': {'customfield_10163': {'type': 'doc',
                                           'version': 1,
                                           'content': [{'type': 'paragraph',
                                                        'content': [{'type': 'text',
                                                                     'text': 'Paragraph written '
                                                                             'as ADF.'}]}]}}},
)
print(r.status_code, r.text)

Response: HTTP 200

{
 "key": "ZZREF-6",
 "fields": {
  "customfield_10163": {
   "type": "doc",
   "version": 1,
   "content": [
    {
     "type": "paragraph",
     "content": [
      {
       "type": "text",
       "text": "Paragraph written as ADF."
      }
     ]
    }
   ]
  }
 }
}

Sent to Atlassian Cloud on .

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

Shows what a plain string gets.

curl

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

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

Response: HTTP 400

{
 "errorMessages": [],
 "errors": {
  "customfield_10163": "Operation value must be an Atlassian Document (see the Atlassian Document Format)"
 }
}

Sent to Atlassian Cloud on .

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

Reads the field with expand=renderedFields; the HTML sits in renderedFields next to the document in fields.

curl

curl -G \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  --data-urlencode 'fields=customfield_10163,customfield_10169,customfield_10170' \
  --data-urlencode 'expand=renderedFields' \
  '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_10163,customfield_10169,customfield_10170', 'expand': 'renderedFields'},
)
print(r.status_code, r.text)

Response: HTTP 200

{
 "key": "ZZREF-6",
 "renderedFields": {
  "customfield_10163": "<p>Paragraph written as ADF.</p>"
 },
 "fields": {
  "customfield_10163": {
   "type": "doc",
   "version": 1,
   "content": [
    {
     "type": "paragraph",
     "content": [
      {
       "type": "text",
       "text": "Paragraph written as ADF."
      }
     ]
    }
   ]
  }
 }
}

Sent to Atlassian Cloud on .

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

The v2 path returns the same stored value as a plain string.

curl

curl -G \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  --data-urlencode 'fields=customfield_10163,customfield_10164,customfield_10170' \
  'https://your-domain.atlassian.net/rest/api/2/issue/{issueIdOrKey}'

Python (requests)

import os
import requests

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

Response: HTTP 200

{
 "key": "ZZREF-6",
 "fields": {
  "customfield_10163": "Paragraph written as ADF."
 }
}

Sent to Atlassian Cloud on .

POST /rest/api/3/search/jql

Searches the paragraph text with ~ and a lower-case term; the work item holding "Checkout total is wrong." matched.

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 paragraph\" ~ \"checkout\"",
  "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 paragraph" ~ "checkout"',
          'fields': ['summary'],
          'maxResults': 2},
)
print(r.status_code, r.text)

Response: HTTP 200

{
 "issues": [
  {
   "key": "ZZREF-11"
  }
 ],
 "isLast": true
}

Sent to Atlassian Cloud on .

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

Edit metadata lists the field 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_10163": {
   "name": "zz-ref paragraph",
   "operations": [
    "set"
   ]
  }
 }
}

Sent to Atlassian Cloud on .

How it behaves

  • Type key com.atlassian.jira.plugin.system.customfieldtypes:textarea, searcher key com.atlassian.jira.plugin.system.customfieldtypes:textsearcher, schema type string, display name "Paragraph (supports rich text)".
  • A document body {"type": "doc", "version": 1, "content": [...]} was accepted with 200 and came back unchanged in fields on v3.
  • A plain string gave 400 with "Operation value must be an Atlassian Document (see the Atlassian Document Format)".
  • With expand=renderedFields the same value appears as <p>Paragraph written as ADF.</p>, and the ~ operator matched the paragraph text regardless of letter case in the term.
  • GET on /rest/api/2/issue/{issueIdOrKey} returned the text "Paragraph written as ADF." in place of the document.

Pitfalls

  • A client written for the v2 API that sends plain strings fails on v3; switch to documents or keep using the v2 path for this field.
  • The error message does not contain the field id in its text; the id is the key in the errors object, so read the key to know which field failed.
  • Formatting is carried only inside the document nodes. Reading through v2 drops it to text.

Questions and answers

Does the paragraph custom field accept a plain string?

Not on v3. The request gave 400 and asked for an Atlassian Document.

How do I get plain text back instead of a document?

Read the work item through the v2 path, which returned the text of the paragraph, or use expand=renderedFields for HTML.

Sources

  1. Issues (Jira REST API v3)
  2. Issue fields (Jira REST API v3)
  3. The Jira Cloud platform REST API v3 (Atlassian Developer)

Markdown version · All Jira fields pages