Question: In case of an error, can I always expect HTTP response body to contain a JSON detailing the error?
Details:
Here is an excerpt from Confluence REST API.
Status codes
The Confluence REST API uses the standard HTTP status codes
Responses that return an error status code will also return a response body, similar to the following:
{
"statusCode": 404,
"data": {
"authorized": false,
"valid": false,
"errors": [
{
"message": {
"translation": "This is an example error message.",
"args": []
}
}
],
"successful": false
},
"message": "This is an example error message."
}
If I understand the documentation correctly, in the event of a 4xx and 5xx error a JSON will be returning in the HTTP response body detailing the error.
But, to test it, when I send a basic REST get request with incorrect token - the response do not contain the JSON in the body. Instead I see a text/plain in the body. Here is an example,
HTTP/1.1 401 Unauthorized
Server: AtlassianProxy/1.19.3.1
Content-Type: text/plain
Strict-Transport-Security: max-age=315360000; includeSubDomains; preload
Date: Sun, 13 Feb 2022 21:42:55 GMT
ATL-TraceId: 6099d826e3a10244
X-XSS-Protection: 1; mode=block
Transfer-Encoding: chunked
X-Content-Type-Options: nosniff
Connection: keep-alive
Expect-CT: report-uri="https://web-security-reports.services.atlassian.com/expect-ct-report/global-proxy", enforce, max-age=86400
Basic authentication with passwords is deprecated. For more information, see: https://developer.atlassian.com/cloud/confluence/deprecation-notice-basic-auth/
In some 404 cases the response body is empty.
Why I am not getting a JSON in the response body in all error cases?