I have a working decoupled/headless setup working using Drupal 8 beta 10 as a backend, and a html5/js webapp as frontend, on seperate servers.

For this scenario, I'm succesfully able to post new content (an article node) as an anonymous user, using the REST /entity/node endpoint.

This works fine, I receive a 201 "Created" response, but now I'm trying to figure out a way to get the ID of this newly created node so I can GET and render it.

The current documentation and response does not provide a return (N)ID. Am I overlooking something or is this a bug?

1 Answer 1


Looking at the response code for POST requests, we can see that there's no body but a header set to the full URI of the node. You can save that URI or explode it/parse it to get just the nid.

  // 201 Created responses have an empty body.
  return new ResourceResponse(NULL, 201, array('Location' => $entity->url('canonical', ['absolute' => TRUE])));
  • Hmmm, yes, but that seems a bit dirty :(
    – askibinski
    May 12, 2015 at 20:39
  • In this context you are supposed to save the full uri anyway, it's the only way to uniquely identify a remote resource isn't it? This or a GUID + base url.
    – Ben
    May 13, 2015 at 2:02
  • Drupal 8 does use UUID's so that would be an option.
    – askibinski
    May 13, 2015 at 7:32

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.