core/modules/rest/src/Plugin/ResourceBase.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/modules/rest/src/Plugin/ResourceBase.php b/core/modules/rest/src/Plugin/ResourceBase.php index 743674f..62e9781 100644 --- a/core/modules/rest/src/Plugin/ResourceBase.php +++ b/core/modules/rest/src/Plugin/ResourceBase.php @@ -120,6 +120,12 @@ public function routes() { : $canonical_path; $route = $this->getBaseRoute($path, $method); + // Allow POST requests to the GET route, so we can respond with a 409 per + // the HTTP spec when POSTing to an existing resource. + if ($method === 'GET' && in_array('POST', $methods, TRUE)) { + $route->setMethods(array_merge($route->getMethods(), ['POST'])); + } + // Note that '_format' and '_content_type_format' route requirements are // added in ResourceRoutes::getRoutesForResourceConfig(). $collection->add("$route_name.$method", $route);