Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 3637

Unable to get POST working with Yii2 RESTful API

$
0
0

I coded a RESTful API in Yii2-Basic using ActiveController and Basic Authentication. I can get the GET method to work, but when I try the Post, using Postman Chrome Extension, it throws an error saying "Method Not Allowed. This url can only handle the following request methods: GET, HEAD.".

Do I need to configure anything on my web server to test this, or require additional functions in the controller? I even tried this with a really simple table with two columns and also set the columns as safe, as hinted in another question.

Appreciate any help in this regard. Below is my current code:

<?phpnamespace app\controllers;use yii\rest\ActiveController;use yii\filters\auth\HttpBasicAuth;class TestController extends ActiveController{    public $modelClass = 'app\models\Test';    public function behaviors()    {        $behaviors = parent::behaviors();        $behaviors['authenticator'] = ['class' => HttpBasicAuth::className(),        ];        return $behaviors;    }}

The URL I am using to test is: http://localhost/test


Viewing all articles
Browse latest Browse all 3637

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>