Problem/Motivation
It's not clear how to POST a comment (and probably other entities having relations like book page, entity referenced entity).
Submitting a node by following the REST+HAL node POST on https://www.drupal.org/node/2098511 is running ok.
Trying to accomplish this for a comment fails with 422 Unprocessable Entity code
without the build message by EntityResource::validate()
Adding throw new \RuntimeException($message); like
<?php
protected function validate(EntityInterface $entity) {
...
throw new \RuntimeException($message);
throw new HttpException(422, $message);
}
}
?>
reveils in apache error log in my case shows
Uncaught PHP Exception RuntimeException: "Unprocessable Entity: validation failed.\nentity_id: This value should not be null.\n" at /.../core/modules/rest/src/Plugin/rest/resource/EntityResource.php line 214
What must I do now?
Proposed resolution
This needs documentation and debugging tools for REST client builders.
Remaining tasks
- Write documentation
- Move forward #1925618: Add documentation for REST link relations
- Should we throw an error or provide a JSON error struct as discussed in #1996130: REST views: not adding dependencies on Serializer providers and #1916302: Serve REST errors as application/api-problem+json OR application/vnd.error+json
Collateral issue:
- Is Symfony in err not using getMessage()? File a bug for Symfony?