mardi 29 août 2017

Laravel API isn't getting inputs

I am developing a REST API in laravel and upon requesting it I am posting some data. But in laravel controller nothing appears. This is my controller code:

try {
      $rules = [
         'type' => 'required|integer'
      ];

      $validator = Validator::make($this->inputs, $rules);
      if ($validator->passes()) {
         //code here
      } else {
         return response()->json([
                'status' => $this->BAD_REQUEST,
                    'response' => [
                        'message' => $validator->messages(),
                        'data' => $this->NO_DATA_ARRAY
                    ],
                ], $this->BAD_REQUEST);
      }
} catch (\Exception $ex) {
            return response()->json([
                'status' => $this->BAD_REQUEST,
                'response' => [
                    'message' => $ex->getMessage(),
                    'data' => $this->NO_DATA_ARRAY
                ],
            ], $this->BAD_REQUEST);
}

Now when I do print_r($this->inputs); I get nothing. I am sending the request from postman and sending the data as form-data. I have tried sending it using an online API tester as well. Still the same result. Any help?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire