REST route not working v 3.6.12 post method landing to index action


#1

Route

Router::scope('/', function (RouteBuilder $routes) {

    Router::prefix('v1', function ($routes) {
        $routes->setExtensions(['json']);
        $routes->resources('Translations');
        $routes->resources('Posts');
        $routes->resources('Sentences');
    });

In controller

public function beforeFilter(Event $event)
{
    parent::beforeFilter($event);

    // $this->getEventManager()->off($this->Security);
    // $this->Security->setConfig('unlockedActions', 'add');
    echo "Action: " . $this->request->getParam('action');
    echo " Method: " . $this->request->getMethod();
    $this->Security->setConfig('validatePost', false);
}

Request

1. Request URL:http://localhost/restcake/v1/translations.json
2. Request Method:POST
3. Status Code:200 OK
4. Remote Address:[::1]:80
5. Referrer Policy:no-referrer-when-downgrade

Reponse

1. Action: index Method: POST{,…}

  1. translations: [{id: "0993a798-dd60-4b49-bd7c-74ad23819850", text: "a fkdjsak fasdf asdfkjas dfkasdj fasdfa",…},…]