POST request is always empty - Laravel 8

Viewed 341

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?

1 Answers

Maybe reformat your json to a valid one (: instead of =)

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