skip to Main Content

We developed our own api for mobile applications, which works on the basis of post requests, but after reinstalling the project on a new server, Yii :: $ app-> request-> post () always returns an empty value. At the same time, Yii :: $ app-> request-> getRawBody () contains a value, but I would not want to rewrite all api.

Tell me what could be the problem and which way to dig? Thanks in advance.

Sending through a mobile application or post through RestClient PHPStorm. Returns emptiness always.

public function behaviors()
{
    return [
        'access' => [
            'class' => AccessControl::class,
            'only' => ['logout', 'signup'],
            'rules' => [
                [
                    'actions' => ['login'],
                    'allow' => true,
                    'roles' => ['?'],
                ],
                [
                    'actions' => ['login'],
                    'allow' => true,
                    'roles' => ['@'],
                ],
            ],
        ],
        'verbs' => [
            'class' => VerbFilter::class,
            'actions' => [
                'login' => ['post', 'get'],
                'token' => ['post', 'get'],
                'logout' => ['post', 'get'],
            ],
        ],
    ];
}

public function beforeAction($action) {
    $this->enableCsrfValidation = false;
    return parent::beforeAction($action);
}

public function actionLogin()
{
    return Yii::$app->request->post("username");
}

2

Answers


  1. Chosen as BEST ANSWER

    After a new reinstallation of the project, the problem resolved by itself. Thanks to all.


  2. Could be your request is by get() method

    $app->request->get();
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search