0x3d
0x3d

Reputation: 470

HTTP POST to Yii2

I'm using Postman ( Chrome extension ) to POST data to my Yii2 application.

I have a method in my SiteController:

public function actionMobileLogin()
{
    echo "MobileLogin";
    var_dump($_POST);
}

When I do post to: [my website]/web?r=site/mobile-login

I get as response only:

MobileLoginarray(0) {
}

I tried to do POST to other php file with same PHP code ( a file that not extends class Controller ), everything is working fine. The problem appears when I do post to a Yii2 action.

What I need to do to receive POST to my Yii2 methods from external Server ?

Upvotes: 0

Views: 676

Answers (1)

I guess it is too late, but you have to override the next attribute in your controller:

public  $enableCsrfValidation = false;

Upvotes: 1

Related Questions