Hi,
I don't know if it is a bug, but when I send GET request to my custom entity, I received an error 500.
The watchdog entry :
Symfony\Component\Routing\Exception\RouteNotFoundException : Route "entity.MY_ENTITY_TYPE.canonical" does not exist. dans Drupal\Core\Routing\RouteProvider->getRouteByName() (ligne 191 de /Applications/MAMP/htdocs/drupal8/core/lib/Drupal/Core/Routing/RouteProvider.php).
It's worry because one of my custom entity without bundle works perfectly.
But, this entity is configured to accept bundles. If I add only one bundle, it's OK. But when I add another bundle and I try to access to one entry of this new bundle via REST, Drupal save this error.
My endpoint :
http//mydrupal.env/MY_ENTITY/3?_format=json
Thanks,
Anthony (french who have bad english)
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | rest.settings.yml | 704 bytes | anthony thomas |
Comments
Comment #2
anthony thomasComment #3
wim leersWhat's the name of your entity type?
Note the error says
MY_ENTITY_TYPEand the URL saysMY_ENTITY.Comment #4
anthony thomasMy entity type : training_entity_type
I have 2 bundles : learn and serious_game
In fact, I don't understand this error, because there is a reference to entity type URL.
Comment #5
wim leersCan you export your
rest.settingsconfiguration and post it?Comment #6
anthony thomasHi,
now it is league the name of my entity.
Thanks.
Comment #7
wim leersSo are you doing GET REST requests to
http://mydrupal.env/league/3?_format=jsonnow then?Comment #8
anthony thomasYes, have just a different endpoint because I don't edit default URI suggest by Drupal Console when I generated the custom entity.
http://mydrupal.env/admin/structure/league/3?_format=json
Error is the same :
Symfony\Component\Routing\Exception\RouteNotFoundException : Route "entity.league_type.canonical" does not exist. dans Drupal\Core\Routing\RouteProvider->getRouteByName() (ligne 191 de /Applications/MAMP/htdocs/drupal8/core/lib/Drupal/Core/Routing/RouteProvider.php).Comment #9
wim leersEh, that's not at all REST, that's just the default route in general. It looks like your problem is in Entity API, in how routes are auto-generated. See #2350503: Add route generation handlers for entities.
I should've noticed that sooner. Moving to the right component.
Comment #10
dietr_ch commentedIn case you still have this problem (or for future readers): Drupal Console adds a canonical link path to your generated entity type config entity, even though the route for the canonical path doesn't exist. You need to remove the
canonicallink from the "links" collection in the@ConfigEntityTypeannotation.Comment #11
sylvain lavielle commented@dietr_ch: thank you so much. that's it !
Comment #12
berdirSounds like that's a bug in drupal console then. Marking this as answered, throwing the exception is the right thing to do for core, if anything, it could maybe explain the problem a bit more.