Going Stellar

Home/Atlassian REST API reference

Jira and Confluence Cloud REST API

Jira and Confluence REST error response formats

There is no single error format across the two products. Jira usually answers with an error collection holding errorMessages and a field-keyed errors map. Confluence v2 answers with an errors array that has status, code and title. Confluence v1 answers with statusCode and message. Gateways and content negotiation add problem+json and plain HTML bodies.

Endpoints

MethodPathWhat it does
POST/rest/api/3/issueField problems come back in the errors map.
GET/wiki/api/v2/pages/{id}Confluence v2 error array.
GET/wiki/rest/api/searchConfluence v1 error shape for a bad CQL expression.

Examples

POST /rest/api/3/issue

Jira field error: the problem is keyed by the field name in errors.

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

Jira request level error: errorMessages carries a sentence and errors stays empty.

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 .

GET /wiki/api/v2/pages/999999999999

Confluence v2 error array with status, code, title and detail.

curl

curl \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  'https://your-domain.atlassian.net/wiki/api/v2/pages/999999999999'

Python (requests)

import os
import requests

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

Response: HTTP 404

{
 "errors": [
  {
   "status": 404,
   "code": "NOT_FOUND",
   "title": "Cannot find a page with id [999999999999]",
   "detail": null
  }
 ]
}

Response headers

Content-Type: application/json

Sent to Atlassian Cloud on .

GET /wiki/rest/api/search

Confluence v1 error with statusCode and a Java exception name inside message.

curl

curl -G \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  --data-urlencode 'cql=space = ' \
  'https://your-domain.atlassian.net/wiki/rest/api/search'

Python (requests)

import os
import requests

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

Response: HTTP 400

{
 "statusCode": 400,
 "message": "com.atlassian.confluence.api.service.exceptions.api.BadRequestException: Expecting a value for operator '=' after field 'space'"
}

Sent to Atlassian Cloud on .

POST /rest/api/3/issue

A 415 in RFC 9457 problem JSON with type, title, status, detail and instance.

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"
}

Response headers

Content-Type: application/problem+json;charset=UTF-8

Sent to Atlassian Cloud on .

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

An HTML error page from the front proxy for a request the platform did not accept.

curl

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

Python (requests)

import os
import requests

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

Response: HTTP 400

<title>400 Bad Request</title>

Sent to Atlassian Cloud on .

How it behaves

  • Jira validation errors set errors to a map from field key to message and leave errorMessages empty, as with issuetype: Specify a valid issue type.
  • Jira request level errors use errorMessages and leave errors empty. A create request with project and issuetype but no summary answered 400 with the message one of 'fields' or 'update' required, which does not name the missing field.
  • Confluence v2 wraps every error in an errors array. Each item has status, code (for example NOT_FOUND), title and a detail that was null in the run.
  • Confluence v1 answered a bad CQL expression with 400, statusCode, a data object that still said valid true and successful true, and a message that quotes the parser error.
  • A PATCH to a work item answered 400 with an nginx HTML page, not 405 and not JSON.

Pitfalls

  • Branch on the HTTP status first, then parse by Content-Type. A client that always calls json() on errors fails on the HTML and plain text bodies.
  • Read both errorMessages and errors on Jira. Checking only one of them loses half the cases.
  • In Confluence v1 the data block can look healthy next to a 400, so do not use data.valid or data.successful as the verdict.
  • The Jira guide documents the error collection schema with errorMessages, errors and an optional status integer. The runs show only the first two.

Questions and answers

Where is the field name in a Jira error?

In the key of the errors object. The value is the human readable message for that field.

Why does my error body not parse as JSON?

Some failures come from the proxy or the CSRF filter. The runs include an HTML 400 and a plain text XSRF message.

Sources

  1. The Jira Cloud platform REST API v3 (Atlassian Developer)
  2. The Confluence Cloud REST API v2 (Atlassian Developer)
  3. Search content by CQL (Confluence REST API v1)

Markdown version · All REST API pages