I'm trying to create new nodes by POSTing to /entity/node?_format=json. This is the body I'm sending:

    "_links": {
        "type": {
            "href": "http:\/\/my.drupal.be\/rest\/type\/node\/group_of_documents"
    "title": [{
        "value": "Direct test - type 682"
    "body": [{
        "value": ""
    "field_owner": [{
        "value": "Symfony"
    "field_type": [{
        "target_id": "682"

And, in a way, this works. Because the document gets made, and everything is filled in.

But I keep getting an error:

A fatal error occurred:
The controller result claims to be providing relevant cache metadata,
but leaked metadata was detected.
Please ensure you are not rendering content too early.
Returned object class: Drupal\rest\ResourceResponse.

If I create a node without field_type, it doesn't throw an error.

field_type is the only field that has the Reference type -> Reference views -> Reference method set to Views: Filter by an entity reference view. Does that have anything to do with it?

  • same happened to me on REST GET when called Url::fromRoute('entity.node.canonical', ['node' => $node->id()], $options); $url->toString();
    – Adi
    Jul 21, 2016 at 15:56
  • Getting the same thing when using snippet similar to @Adi Mar 25, 2017 at 15:12

2 Answers 2


That's a core bug, see https://www.drupal.org/node/2626298 and https://www.drupal.org/node/2663638 (either of those two would avoid this).

The views reference thing is a good hint. Sounds something runs there that then triggers this exception. You could open an issue for that too if you can find the exact reason.


Try changing response to (maybe helps you) after you save node, because ResourceResponse is cachable...in this way we don't cache POST method.

return new ModifiedResourceResponse($node);


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.