Getting error {"message":"No route found for \u0022GET \/standortimporter\/region_node_rest_resource\u0022"} custom rest POST
To create a custom rest resource:


Enable rest module: drush en rest -y
Create the plugin like the following YOURMODULENAME/src/Plugin/rest/resource/RegionNodeRestResource.php:




namespace Drupal\YOURMODULENAME\Plugin\rest\resource;

use Drupal\rest\ModifiedResourceResponse;
use Drupal\rest\Plugin\ResourceBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;

/**
 * Provides a resource to get view modes by entity and bundle.
 *
 * @RestResource(
 *   id = "region_node_rest_resource",
 *   label = @Translation("Region node rest resource"),
 *   uri_paths = {
 *     "create" = "/standortimporter/region-node-rest-resource"
 *   }
 * )
 */
class RegionNodeRestResource extends ResourceBase {

  /**
   * A current user instance.
   *
   * @var \Drupal\Core\Session\AccountProxyInterface
   */
  protected $currentUser;

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    $instance = parent::create($container, $configuration, $plugin_id, $plugin_definition);
    $instance->currentUser = $container->get('current_user');
    return $instance;
  }

    /**
     * Responds to POST requests.
     *
     * @param string $payload
     *
     * @return \Drupal\rest\ModifiedResourceResponse
     *   The HTTP response object.
     *
     * @throws \Symfony\Component\HttpKernel\Exception\HttpException
     *   Throws exception expected.
     */
    public function post($payload) {

        // You must to implement the logic of your REST Resource here.
        // Use current user after pass authentication to validate access.
        if (!$this->currentUser->hasPermission('access content')) {
            throw new AccessDeniedHttpException();
        }

      $payload = ["hello here"];
        return new ModifiedResourceResponse($payload, 200);
    }

}




You should enable your resource using restui:
go to admin/config/services/rest you can see your endpoint and enable it.



And configure it like the following:

 4. To test you should use rest client app like Postman like:


For more informations read Custom REST Resources page.