In my controller:
namespace app\api\modules\v1\controllers; use yii\rest\ActiveController; use yii\filters\VerbFilter; use yii\web\Response; class CountryController extends ActiveController { public $modelClass = 'app\models\Country'; public function behaviors() { return [ [ 'class' => 'yii\filters\ContentNegotiator', 'only' => ['index', 'view','create','update','search'], 'formats' => ['application/json' =>Response::FORMAT_JSON,], ], 'verbs' => [ 'class' => VerbFilter::className(), 'actions' => [ 'index'=>['get'], 'view'=>['get'], 'create'=>['post'], 'update'=>['PUT'], 'delete' => ['delete'], 'deleteall'=>['post'], 'search' => ['get'] ], ] ]; } }'
I am trying from my postman application
For creation, I use POST http: // localhost / myapp / api / v1 / countries. It works fine. But for the update, I use PUT http: // localhost / myapp / api / v1 / country / 16 returns a 16 record as JSON output is not updated as expected.
What happened? Thanks!!
source share