I am creating a custom rest resource.
/**
* Provides a resource to update nodes.
*
* @RestResource(
* id = "my_custom_resource",
* label = @Translation("Custom rest resource"),
* uri_paths = {
* "canonical" = "/custom-api/{node}",
* }
* )
*/
class MyCustomResource extends ResourceBase {
public function patch(EntityInterface $entity, $data = []): ResourceResponse {
return new ResourceResponse('Some message', 200);
}
}
But when I try to send a patch request from my postman using the URL http://mysite/custom-api/2169
, I am getting an error
RuntimeException: Callable "Drupal\my_module\Plugin\rest\resource\MyCustomResource::patch" requires a value for the "$entity" argument. in Drupal\Component\Utility\ArgumentsResolver->handleUnresolvedArgument() (regel 143 van /var/www/web/core/lib/Drupal/Component/Utility/ArgumentsResolver.php).
What can be the problem? How can I get the argument?