POST not allowed

Всё что касается построения API
Ответить
a.k.
Сообщения: 56
Зарегистрирован: 2014.11.29, 10:39

POST not allowed

Сообщение a.k. »

Добрый день.
Не пойму почему не работает.
Контроллер:

Код: Выделить всё

<?php

namespace app\controllers;

use yii\rest\ActiveController;
use yii\data\ActiveDataProvider;
use app\models\Feedback;

class FeedbackController extends ActiveController
{
    public $modelClass = 'app\models\Feedback';
    
    public function actions()
    {
        $actions = parent::actions();
    
        // disable the "delete" and "update" actions
        unset($actions['delete'], $actions['update'], $actions['options']);
        return $actions;
    }
}
?>
// RULES CONFIG:
<?
'rules' => [
                ['class' => 'yii\rest\UrlRule', 'controller' => ['feedback','comments']],
                '<_c:[\w\-]+>/<id:\d+>' => '<_c>/view',
                '<_c:[\w\-]+>' => '<_c>/index',
                '<_c:[\w\-]+>/<_a:[\w\-]+>/<id:\d+>' => '<_c>/<_a>',
            ],
?>
При этом отправка POST cooments работает, а feedback нет:

Код: Выделить всё

<response>
<name>Method Not Allowed</name>
<message>
Method Not Allowed. This url can only handle the following request methods: GET, HEAD.
</message>
<code>0</code>
<status>405</status>
<type>yii\web\MethodNotAllowedHttpException</type>
</response> 
a.k.
Сообщения: 56
Зарегистрирован: 2014.11.29, 10:39

Re: POST not allowed

Сообщение a.k. »

['class' => 'yii\rest\UrlRule', 'controller' => 'feedback', 'pluralize'=>false],
Правило должно быть таким, все дело в PLURALIZE - добавляет S в соответствии с правилами (feedbacks вместо feedback)
Ответить