Details
-
Story
-
Resolution: Fixed
-
High
-
2015.07, 1.3.1, 1.4.1
-
None
Description
Right now, if a draft can not be saved/created, the REST API generates a 400 response with the following content:
{ "ErrorMessage": { "_media-type": "application\/vnd.ez.api.ErrorMessage+json", "errorCode": 400, "errorMessage": "Bad Request", "errorDescription": "Value for required field definition 'user_account' with language 'eng-GB' is empty", "trace": "<stack trace>", "file": "\/home\/dp\/dev\/ezplatform\/vendor\/ezsystems\/ezpublish-kernel\/eZ\/Publish\/Core\/REST\/Server\/Controller\/Content.php", "line": 248 } }
It's hard for a REST API consumer (PlatformUI for instance) to know what exactly went wrong and in addition only the first validation error is described. It would be nice if the REST API could provide more details in a structured way. For instance, when a required field (user_account) is not provided and a invalid content is provided (in an email field), the response could be something like:
{ "ErrorMessage": { "_media-type": "application\/vnd.ez.api.ErrorMessage+json", "errorCode": 400, "errorMessage": "Bad Request", "errorDescription": "Validation fails on several fields", "errorDetails": { "fields": { "user_account": { type: "empty", message: "Value for required field definition 'user_account' with language 'eng-GB' is empty" }, "email": { type: "syntax", message: "The provided email is invalid" } } } "trace": "<stack trace>", "file": "\/home\/dp\/dev\/ezplatform\/vendor\/ezsystems\/ezpublish-kernel\/eZ\/Publish\/Core\/REST\/Server\/Controller\/Content.php", "line": 248 } }
error details in errorDetails.fields are indexed by field definition identifier and the type values are just examples and are to be defined.