I am sending data in json format using postman to my server in Laravel 4.2,
{ "id_servicio" = "8", "user_token" = "3853656261737469616e3130" } to receive all infomation I use the Input::json()->all()method but this nothing recive and apper Error Undefined index: user_token error.
My code:
Route
Route::post('motoboy/service/finish/info', array('uses' => 'ServicioController@finishServicio')); Controller
function finishServicio(){ $input = Input::json()->all(); $token = $input['user_token']; // Error in this part $idServicio = $input['id_servicio']; $servicio = DB::table('servicios')->where('id_servicio', $idServicio)->first(); $motoboy = DB::table('motoboys')->where('auth_token', $token)->first(); if($motoboys != null){ if($servicio != null){ $array = array('Code' => '202', 'Message' => 'EL servicio existe y está listo para recibir las imagenes'); return Response::json($array); }else{ $array = array('Error' => 'Servicio no encontrada', 'Code' => '404', 'Message' => 'Servicio no encontrado'); return Response::json($array); } }else{ $array = array('Error' => 'Motoboy no autentificado', 'Code' => '401', 'Message' => 'Motoboy no autentificado'); return Response::json($array); } } When I use dd($input) function, return this array{0} How can I fix it?
Edit
I am sending information from Android app to my server in laravel. I am using GSON to send the information in JSON Format, for this reason I need to use Input::json()->all() because receive the input in JSON, if I use Input::all() and I send a JSOn, that method doesnt receive nothing