Jira Cloud fields and work types
Jira fields on screens: tab listing and refused fields
A screen tab lists its fields at GET /rest/api/3/screens/{screenId}/tabs/{tabId}/fields, POST adds a field and DELETE removes one. Editing a work item did not check the tab: a field taken off the tab was still set with 204. The error 'not on the appropriate screen, or unknown' is generic and also appears for a field that is on the tab.
Endpoints
| Method | Path | What it does |
|---|---|---|
GET | /rest/api/3/screens/{screenId}/tabs/{tabId}/fields | Lists the fields of one screen tab. |
POST | /rest/api/3/screens/{screenId}/tabs/{tabId}/fields | Adds a field to a screen tab. |
DELETE | /rest/api/3/screens/{screenId}/tabs/{tabId}/fields/{id} | Removes a field from a screen tab. |
POST | /rest/api/3/screens/addToDefault/{fieldId} | Adds a field to the default tab of the default screen. |
Examples
GET /rest/api/3/screens/{screenId}/tabs/{tabId}/fields
Reads the tab of the project's screen. The answer is a plain array of id and name pairs, system fields first and the added custom fields after them.
curl
curl \
-u "you@example.com:$ATLASSIAN_API_TOKEN" \
-H 'Accept: application/json' \
'https://your-domain.atlassian.net/rest/api/3/screens/{screenId}/tabs/{tabId}/fields'Python (requests)
import os
import requests
EMAIL = "you@example.com"
r = requests.get(
'https://your-domain.atlassian.net/rest/api/3/screens/{screenId}/tabs/{tabId}/fields',
auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
headers={'Accept': 'application/json'},
)
print(r.status_code, r.text)Response: HTTP 200
[
{
"id": "summary",
"name": "Summary"
},
{
"id": "issuetype",
"name": "Issue Type"
},
{
"id": "assignee",
"name": "Assignee"
},
{
"id": "duedate",
"name": "Due date"
},
{
"id": "description",
"name": "Description"
},
{
"id": "priority",
"name": "Priority"
},
{
"id": "labels",
"name": "Labels"
},
{
"id": "attachment",
"name": "Attachment"
},
{
"id": "parent",
"name": "Parent"
},
{
"id": "customfield_10001",
"name": "Team"
},
{
"id": "customfield_10015",
"name": "Start date"
},
{
"id": "customfield_10142",
"name": "Category"
},
{
"id": "reporter",
"name": "Reporter"
},
{
"id": "customfield_10162",
"name": "zz-ref text"
}
]Response headers
X-Ratelimit-Limit: 350
X-Ratelimit-Remaining: 349Sent to Atlassian Cloud on .
POST /rest/api/3/screens/{screenId}/tabs/{tabId}/fields
Adds a newly created custom field to the tab. The answer is the field's id and name.
curl
curl -X POST \
-u "you@example.com:$ATLASSIAN_API_TOKEN" \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
--data '{
"fieldId": "customfield_10222"
}' \
'https://your-domain.atlassian.net/rest/api/3/screens/{screenId}/tabs/{tabId}/fields'Python (requests)
import os
import requests
EMAIL = "you@example.com"
r = requests.post(
'https://your-domain.atlassian.net/rest/api/3/screens/{screenId}/tabs/{tabId}/fields',
auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
headers={'Accept': 'application/json'},
json={'fieldId': 'customfield_10222'},
)
print(r.status_code, r.text)Response: HTTP 200
{
"id": "customfield_10222",
"name": "zz-ref created in probe"
}Sent to Atlassian Cloud on .
POST /rest/api/3/screens/{screenId}/tabs/{tabId}/fields
Adds the same field a second time. Jira answers 400 keyed on fieldId.
curl
curl -X POST \
-u "you@example.com:$ATLASSIAN_API_TOKEN" \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
--data '{
"fieldId": "customfield_10222"
}' \
'https://your-domain.atlassian.net/rest/api/3/screens/{screenId}/tabs/{tabId}/fields'Python (requests)
import os
import requests
EMAIL = "you@example.com"
r = requests.post(
'https://your-domain.atlassian.net/rest/api/3/screens/{screenId}/tabs/{tabId}/fields',
auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
headers={'Accept': 'application/json'},
json={'fieldId': 'customfield_10222'},
)
print(r.status_code, r.text)Response: HTTP 400
{
"errorMessages": [],
"errors": {
"fieldId": "The field with id customfield_10222 already exists on the screen."
}
}Sent to Atlassian Cloud on .
DELETE /rest/api/3/screens/{screenId}/tabs/{tabId}/fields/customfield_10222
Removes the field from the tab. 204 with no body.
curl
curl -X DELETE \
-u "you@example.com:$ATLASSIAN_API_TOKEN" \
-H 'Accept: application/json' \
'https://your-domain.atlassian.net/rest/api/3/screens/{screenId}/tabs/{tabId}/fields/customfield_10222'Python (requests)
import os
import requests
EMAIL = "you@example.com"
r = requests.delete(
'https://your-domain.atlassian.net/rest/api/3/screens/{screenId}/tabs/{tabId}/fields/customfield_10222',
auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
headers={'Accept': 'application/json'},
)
print(r.status_code, r.text)Response: HTTP 204
No response body.
Sent to Atlassian Cloud on .
PUT /rest/api/3/issue/{issueIdOrKey}
Sets a value on that field after it left the tab. The edit still succeeds with 204.
curl
curl -X PUT \
-u "you@example.com:$ATLASSIAN_API_TOKEN" \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
--data '{
"fields": {
"customfield_10222": "x"
}
}' \
'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}'Python (requests)
import os
import requests
EMAIL = "you@example.com"
r = requests.put(
'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}',
auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
headers={'Accept': 'application/json'},
json={'fields': {'customfield_10222': 'x'}},
)
print(r.status_code, r.text)Response: HTTP 204
No response body.
Sent to Atlassian Cloud on .
PUT /rest/api/3/issue/{issueIdOrKey}
Sets reporter, which the tab lists. The edit is refused with the screen wording.
curl
curl -X PUT \
-u "you@example.com:$ATLASSIAN_API_TOKEN" \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
--data '{
"fields": {
"reporter": {
"accountId": "<accountId>"
}
}
}' \
'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}?returnIssue=true&fields=reporter'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=reporter',
auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
headers={'Accept': 'application/json'},
params={'returnIssue': 'true', 'fields': 'reporter'},
json={'fields': {'reporter': {'accountId': '<accountId>'}}},
)
print(r.status_code, r.text)Response: HTTP 400
{
"errorMessages": [],
"errors": {
"reporter": "Field 'reporter' cannot be set. It is not on the appropriate screen, or unknown."
}
}Sent to Atlassian Cloud on .
GET /rest/api/3/issue/{issueIdOrKey}/editmeta
Edit metadata for the same work item. It includes comment, environment and the Flagged field, which the tab listing does not, and leaves out reporter.
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": {
"comment": {
"name": "Comment",
"operations": [
"add",
"edit",
"remove"
]
},
"environment": {
"name": "Environment"
},
"customfield_10021": {
"name": "Flagged",
"operations": [
"add",
"set",
"remove"
]
}
}
}Sent to Atlassian Cloud on .
How it behaves
- The tab listing held 33 fields. All 20 test custom fields were on it, plus nine system fields, reporter and three built-in custom fields.
- POST answered 200 with {id, name}; the same call again answered 400 with errors.fieldId = 'The field with id customfield_10222 already exists on the screen.'; DELETE answered 204.
- After the field was removed from the tab, PUT on a work item with that field answered 204. The edit did not depend on the tab.
- reporter was on the tab, yet writing it answered 400 with errors.reporter = "Field 'reporter' cannot be set. It is not on the appropriate screen, or unknown.", and edit metadata did not list it.
- Edit metadata listed 35 fields. comment, environment and the Flagged field were not on the tab that was read, so one tab listing is not the full set of editable fields.
Pitfalls
- The wording 'not on the appropriate screen, or unknown' is shared by several causes and can be misleading, as the reporter case shows. Compare edit metadata before moving fields around.
- Removing a field from a tab hides it from the screen but, in the run, did not stop an API edit. Do not use a screen as a write guard.
- A tab listing says what is on that tab only. Use editmeta or createmeta to learn what a given work item accepts.
Questions and answers
How do I put a custom field on a screen?
POST /rest/api/3/screens/{screenId}/tabs/{tabId}/fields with the field id, or POST /rest/api/3/screens/addToDefault/{fieldId} for the default screen. Both need Administer Jira.
Why is a field I can see on the screen refused on edit?
The message is generic. In the run, reporter was on the tab and still refused; edit metadata did not list it.
Related
- Which fields can be set: editmeta and createmeta
- Field configurations
- Create a custom field: types and searchers
- Trash, restore and delete a custom field
- reporter
- Team-managed vs company-managed projects