POST request is always empty – Laravel 8

  laravel, php, post, request

I am using PHP 8.0.7, Laravel 8.41.0 and new to Laravel. Building some simple APIs. No issues with GET APIs but having trouble with POST.

The $request object is always empty no matter what I did. It just returns [].

I am posting below data in Fiddler :

User-Agent: Fiddler
Content-Type: application/json

{
"parent_id" = "1",
"process_no" = "20",
"process_name" = "Aux Electrical",
"level" = "4",
"priority_no" = "1"
}

I tried to dump $request contents in api.php to no avail.

Route::post('/processtree', function (Request $request){
    return $request->all();
});

I tried all sorts of different versions of reading $request object, again did not work. ALl I get is [].

Any ideas what might be wrong here?

Source: Ask PHP

LEAVE A COMMENT