Reputation: 1187
We are working with our api using laravel. When we test our api, there is one method that not accepting any request even in postman. But if I write down the parameters in the url it accepts the method. Can someone know what is the problem with this one?
Method
public function store(Request $request)
{
$studid = User::find($request->user_id);
if(empty($studid))
return response()->json([
'code' => '03',
'status' => 'Invalid Student ID'
], 403);
if($studid->role != 4)
return response()->json([
'code' => '03',
'status' => 'Invalid Student ID'
], 403);
$parentid = User::find($studid->parent_id);
$schattlog = new SchAttlog;
$schattlog->user_id = $studid->id;
$schattlog->school_id = $studid->school_id;
$schattlog->log_type = $request->log_type;
$schattlog->log_date = $request->log_date;
$schattlog->log_timefrom = $request->log_timefrom;
$schattlog->log_timeto = $request->log_timeto;
$schattlog->status = 1;
$schattlog->save();
return response()->json([
'code' => '01',
'status' => 'Student Logged'
]);
}
Postman response using form-data payload
Postman response when values put in the url directly
the url i put is http://127.0.0.1:8000/api/inx/sal?user_id=10&log_type=in&log_date=2019-11-11&log_timefrom=500&log_timeto=500&school_id=1
Upvotes: 0
Views: 1351
Reputation: 8348
In the past i ran also in that issue using patch in postman.
The solution is to use the x-www-form-urlencode
tab instead of form-data
Upvotes: 4