Once REST UI is enabled and configured for REST calls on node entities, any new Content Types (which are defined after the REST UI has been created) give the following error during POST & PATCH hal+json calls to the site:
{"error":"Type http:[drupal path]/[**new content type***] does not correspond to an entity on this site."}

Workaround: Uninstall and then Reinstall REST UI module after creating a new Content Type

Configuration details:
Drupal core: drupal 8.0.0-rc1 OR drupal 8.0.0-rc2
Drupal modules (in addition to standard Drupal install):

  • HAL
  • HTTP Basic Authentication
  • RESTful Web Services
  • Serialization
  • REST UI

REST UI Configuration for Content resource - //node/(node):

  • GET - authentication: basic_auth, cookie - formats: hal_json, json
  • POST - authentication: basic_auth, cookie - formats: hal_json, json
  • DELETE - authentication: basic_auth, cookie - formats: hal_json, json
  • PATCH - authentication: basic_auth, cookie - formats: hal_json, json

Comments

ptwob132 created an issue. See original summary.

clemens.tolboom’s picture

The exception is thrown by the serializer which AFAIK is way past Rest UI scope.

modules/hal/src/Normalizer/ContentEntityNormalizer.php
249: throw new UnexpectedValueException(sprintf('Type %s does not correspond to an entity on this site.', $type_uri));

My guess is you either have found a core bug or provide a wrong type. Unfortunately my test tool to patch is still broken so cannot reproduce yet.

Some additional questions
- What was the result from a drush cache-rebuild?
- Have you set node permissions for the new content type?

ptwob132’s picture

Thanks for the follow-up. Here are my answers:

- What was the result from a drush cache-rebuild?
It then works correctly. This fixed the issue without the workaround.

- Have you set node permissions for the new content type?
Yes, permissions were set correctly

Since clearing the cache fixed the issue, I agree that this is a core bug and not related to this module. You can close this bug. Thanks!

clemens.tolboom’s picture

Status: Active » Closed (works as designed)

Hmmm ... reading the message

"error":"Type http:[drupal path]/[**new content type***] does not correspond to an entity on this site."}

the path should be /node?_format=hal_json I guess.

I close this as works as designed.

vivekvpandya’s picture

I am using Drupal 8.2.1 and REST UI 8.x-1.13.
I am trying to POST and PATCH an entity of the same type (new created type). Here order of request is not determined. But what happens is if I do POST then I can do it successfully many times after that if I do PATCH then it shows me following error:

"Type http://172.17.24.80/dr8.2.1/rest/type/node/trip does not correspond to an entity on this site."

So I found a fix for this from https://www.drupal.org/node/2599364

now after refreshing drupal cache I am able to do PATCH (many times) successfully but after that if I do POST then I get same above mentioned error. So I need to refresh cache every time I change my request type.

how to fix this?
Please help

clemens.tolboom’s picture

@vivekvpandya your question is about core cache and done on a closed issue. Please don't :-)

I guess you meant cache rebuild did the trick as in #2599364-2: New Content Type does not correspond to an entity on this site so you have to search for / report a core bug.

gvso’s picture

Status: Closed (works as designed) » Active

the path should be /node?_format=hal_json I guess.

When using /node?_format=hal_json I got 403 errors. I've tried with various users (with the right permissions) as well as with the admin (user 0)

Wim Leers’s picture

Since clearing the cache fixed the issue, I agree that this is a core bug and not related to this module. You can close this bug. Thanks!

That means this is very likely a duplicate of #2815845: Importing (deploying) REST resource config entities should automatically do the necessary route rebuilding.