nel mio controllerYii2 API REST metodo PUT non funziona
` namespace app \ api \ moduli \ v1 \ controllori;
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']
],
]
];
}
}`
cerco dal mio POSTINO App
Per creo io uso POST http://localhost/myapp/api/v1/countries Opere fine.But Per Aggiornamento io l'impiego, mettere http://localhost/myapp/api/v1/countries/16 restituisce 16 record come uscita JSON non aggiornare come previsto.
Cosa c'era di sbagliato? Grazie!!
Se la chiamata PUT restituisce l'oggetto corretto sembra che l'updateAction sta lavorando bene. Sei sicuro che i valori che stai postando siano nel set di 'rules()'? – jagsler