Not getting required Post value using Yii::$app->request->post()

Doubt i handling formData in Rest and Normal template.

In Controller

public function actionNewStudent()



   $postValue = Yii::$app->request->post();


In view controller of angularJs// which invoke on form submission

// on submit function 

            $scope.submit = function() {

                var myUrl = "";

                var formData = $("#wizard_enrollment_form").serialize();


                    method: 'POST',

                    url: myUrl,

                    data: formData,

                }).success(function (data) {

                    console.log("Success fully submitted");

               }).error(function (data) {

                    console.log("Something went wrong ... Error .");




In default template , there is no problem in getting post value, and load the post value in object $model->load($postValue).

and output var_dump(Yii::$app->request->post()) =

array(2) {


  string(56) "a0huX2dDRFYRIl80ICAVARE8JzwzFyslWHpDCCkkcW8CCw0KKC81MQ=="


  array(10) {


    string(0) ""


But in rest controller,

output var_dump(Yii::$app->request->post()) = it throws error , it is not response format,

so , i changed the formData value as



the output of var_dump(Yii::$app->request->post()) is

string(1112) "Lookup1%type%5D=&Lookup1%5Bcode%5D="

$_POST returns the empty array.

so here, i am cant able to use


i stuck in this please help.

api config is mentioned like this

'parsers' => [

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


and My controller behaviour is

    public function behaviors()


        return ArrayHelper::merge(parent::behaviors(), [

            'verbs' => [

                'class' => VerbFilter::className(),

                'actions' => [






All other functionalities are run without problem using REST, but to submit form is stucked,

In view ,input fields are mentioned as

<input type="text" name="Lookup1[name]" id="lookup1-name" required class="md-input"  md-input ng-model="" />

Please help !!! .Thanks in advance.

I stuck in this. Please anybody know the issue please give solution for this.I dont know how its work, How the post values are differentiated that i mentioned above.

Might be a problem regarding the routing and urlManager rules? I’m not very sure.

what’s the exact error message on this? post the stack trace

Thanks for your response.

Next yii\web\BadRequestHttpException: Invalid JSON data in request body: Syntax error. in /var/www/html1/angular-yii2-ilaiya/vendor/yiisoft/yii2/web/JsonParser.php:54

Stack trace:

#0 /var/www/html1/angular-yii2-ilaiya/vendor/yiisoft/yii2/web/Request.php(394): yii\web\JsonParser->parse('UserModel%5Bfir...', 'application/jso...')

#1 /var/www/html1/angular-yii2-ilaiya/vendor/yiisoft/yii2/web/Request.php(450): yii\web\Request->getBodyParams()

#2 /var/www/html1/angular-yii2-ilaiya/api/modules/v1/controllers/StudentEnrollmentController.php(121): yii\web\Request->post()

#3 [internal function]: api\modules\v1\controllers\StudentEnrollmentController->actionNewStudent()

#4 /var/www/html1/angular-yii2-ilaiya/vendor/yiisoft/yii2/base/InlineAction.php(55): call_user_func_array(Array, Array)

#5 /var/www/html1/angular-yii2-ilaiya/vendor/yiisoft/yii2/base/Controller.php(151): yii\base\InlineAction->runWithParams(Array)

#6 /var/www/html1/angular-yii2-ilaiya/vendor/yiisoft/yii2/base/Module.php(455): yii\base\Controller->runAction('new-student', Array)

#7 /var/www/html1/angular-yii2-ilaiya/vendor/yiisoft/yii2/web/Application.php(84): yii\base\Module->runAction('v1/student-enro...', Array)

#8 /var/www/html1/angular-yii2-ilaiya/vendor/yiisoft/yii2/base/Application.php(375): yii\web\Application->handleRequest(Object(yii\web\Request))

#9 /var/www/html1/angular-yii2-ilaiya/api/web/index.php(18): yii\base\Application->run()

#10 {main}

2016-01-22 04:20:38 [][-][-][info][application] $_COOKIE = [

    '_csrf' => '4e94fbaa2cd69de1bc4b4bb4c3e280d86fc3c26f2313fe223aed155e7bf14591a:2:{i:0;s:5:\"_csrf\";i:1;s:32:\"inFXZ9yhQ_YEsWBShfyPHBndbUOCTObe\";}'