Going Stellar

Home/Atlassian REST API reference

Jira and Confluence Cloud REST API

Jira create work item errors and what they mean

A failed create answers 400 with errorMessages for general problems and an errors object keyed by field id. The same project problem can appear in both. A wrong Content-Type is a different shape altogether: a 415 problem+json body.

Endpoints

MethodPathWhat it does
POST/rest/api/3/issueCreates a work item; each failure below comes from this endpoint.

Examples

POST /rest/api/3/issue

A body whose fields hold a project and a type but no summary.

curl

curl -X POST \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  --data '{
  "fields": {
    "project": {
      "key": "WEB"
    },
    "issuetype": {
      "name": "Task"
    }
  }
}' \
  'https://your-domain.atlassian.net/rest/api/3/issue'

Python (requests)

import os
import requests

EMAIL = "you@example.com"
r = requests.post(
    'https://your-domain.atlassian.net/rest/api/3/issue',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
    json={'fields': {'project': {'key': 'WEB'}, 'issuetype': {'name': 'Task'}}},
)
print(r.status_code, r.text)

Response: HTTP 400

{
 "errorMessages": [
  "one of 'fields' or 'update' required"
 ],
 "errors": {}
}

Sent to Atlassian Cloud on .

POST /rest/api/3/issue

An issue type name that does not exist in the project.

curl

curl -X POST \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  --data '{
  "fields": {
    "project": {
      "key": "WEB"
    },
    "issuetype": {
      "name": "NoSuchType"
    },
    "summary": "x"
  }
}' \
  'https://your-domain.atlassian.net/rest/api/3/issue'

Python (requests)

import os
import requests

EMAIL = "you@example.com"
r = requests.post(
    'https://your-domain.atlassian.net/rest/api/3/issue',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
    json={'fields': {'project': {'key': 'WEB'},
                     'issuetype': {'name': 'NoSuchType'},
                     'summary': 'x'}},
)
print(r.status_code, r.text)

Response: HTTP 400

{
 "errorMessages": [],
 "errors": {
  "issuetype": "Specify a valid issue type"
 }
}

Sent to Atlassian Cloud on .

POST /rest/api/3/issue

A project key that does not exist or cannot be written to.

curl

curl -X POST \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  --data '{
  "fields": {
    "project": {
      "key": "NOPE"
    },
    "issuetype": {
      "name": "Task"
    },
    "summary": "x"
  }
}' \
  'https://your-domain.atlassian.net/rest/api/3/issue'

Python (requests)

import os
import requests

EMAIL = "you@example.com"
r = requests.post(
    'https://your-domain.atlassian.net/rest/api/3/issue',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
    json={'fields': {'project': {'key': 'NOPE'}, 'issuetype': {'name': 'Task'}, 'summary': 'x'}},
)
print(r.status_code, r.text)

Response: HTTP 400

{
 "errorMessages": [
  "The target project doesn't exist or you don't have permission to create issues in it."
 ],
 "errors": {
  "project": "The target project doesn't exist or you don't have permission to create issues in it."
 }
}

Sent to Atlassian Cloud on .

POST /rest/api/3/issue

A plain string where v3 expects an ADF document.

curl

curl -X POST \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  --data '{
  "fields": {
    "project": {
      "key": "WEB"
    },
    "issuetype": {
      "name": "Task"
    },
    "summary": "Plain string description",
    "description": "plain string"
  }
}' \
  'https://your-domain.atlassian.net/rest/api/3/issue'

Python (requests)

import os
import requests

EMAIL = "you@example.com"
r = requests.post(
    'https://your-domain.atlassian.net/rest/api/3/issue',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
    json={'fields': {'project': {'key': 'WEB'},
                     'issuetype': {'name': 'Task'},
                     'summary': 'Plain string description',
                     'description': 'plain string'}},
)
print(r.status_code, r.text)

Response: HTTP 400

{
 "errorMessages": [],
 "errors": {
  "description": "The field value is not valid Atlassian Document Format (ADF) content."
 }
}

Sent to Atlassian Cloud on .

POST /rest/api/3/issue

A body sent as text/plain. The response is problem+json, not the errorMessages shape.

curl

curl -X POST \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  -H 'Content-Type: text/plain' \
  --data '{
  "fields": {}
}' \
  'https://your-domain.atlassian.net/rest/api/3/issue'

Python (requests)

import os
import requests

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

Response: HTTP 415

{
 "type": "about:blank",
 "title": "Unsupported Media Type",
 "status": 415,
 "detail": "Content-Type 'text/plain' is not supported.",
 "instance": "/rest/api/3/issue"
}

Sent to Atlassian Cloud on .

How it behaves

  • Field problems are reported under errors with the field id as the key, for example issuetype and description. General problems are strings in errorMessages.
  • The unknown-project error appeared twice in one body: once in errorMessages and once under errors.project.
  • Leaving summary out did not give a field error for summary. The message was "one of 'fields' or 'update' required", which points at the wrong cause.
  • A wrong Content-Type is rejected before validation with 415 and a problem+json body that has type, title, status, detail and instance.
  • The 400 bodies always had both keys, errorMessages and errors, with one of them empty unless the error was a project problem.

Pitfalls

  • Do not parse only errorMessages. Most field mistakes are in errors, and a client that reads one of the two will miss half of them.
  • When you see "one of 'fields' or 'update' required", check the body for a missing required field such as summary before suspecting the envelope.
  • Error text is for people. Match on the field key or status code in code, because the wording can change.

Questions and answers

Why do I get 400 for a project I can see?

The message says the project does not exist or you cannot create issues in it. The spec lists Browse projects and Create issues as the required permissions.

Is there a way to get field-level errors only?

The spec describes an experimental preferFieldAssociatedErrors parameter that moves more errors into the errors object. It is marked experimental and was not tried.

Sources

  1. The Jira Cloud platform REST API v3 (Atlassian Developer)
  2. Create issue (Jira REST API v3)

Markdown version · All REST API pages