Yii2 rest Method Not Allowed?


(Des1roer) #1

config https://github.com/des1roer/yii2test/blob/master/config/web.php

api module https://github.com/des1roer/yii2test/tree/master/modules/api

how repair?


(Yiiframework) #2

Is this missing from your config?

http://www.yiiframework.com/doc-2.0/guide-rest-quick-start.html#configuring-url-rules


(Des1roer) #3

[‘class’ => ‘yii\rest\UrlRule’, ‘controller’ => ‘api/unit’], don`t work


(Stefano Mtangoo) #4

If anyone hits same issue make sure that you have request enabled to handle JSON


'request' => [

	'parsers' => [

    	'application/json' => 'yii\web\JsonParser',

	]

]


(Peter Verbrugge) #5

It seems you can not do a delete when you don’t have a token set in the rules. For some reason the delete method is then not allowed.