Level 6
Try to send the postman request as JSON, not form-data. For example:
{
"user_id": 5
}
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have an admin user who can create all the listings and am using API with postman to retrieve listings that belongs to a user.
My ListingController:
public function getListing(Request $request){
$listings = Listing::where('user_id',$request->input('user_id'))->get();
if($listings->isEmpty()){
return response(['error' => 'No records found']);
}
return response([
'status' => 200,
'message' => 'success',
'result' => [
'data' => $listings,
],
]);
}
api.php:
//Route for get listing
Route::middleware(['auth:api'])->group(function () {
Route::get('/listing/get','API\ListingController@getListing');
});
While in postman, I added an authorize token from passport and added a user_id in the body - form-data - key section and hit send but it always return with no records found
The issue I am guessing if it could not receive the user id input but how come it does not work?
Please or to participate in this conversation.