Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 295966

How to POST a comment and other relational entities

$
0
0

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 codewithout 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

Collateral issue:

  • Is Symfony in err not using getMessage()? File a bug for Symfony?
  • User interface changes

    API changes


Viewing all articles
Browse latest Browse all 295966

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>