What do you mean "a string not a json"? JSON is a string before you decode it. What does it contain?
$request->getContent() isn't an objcet
Hi Laracasts community. I'm using Laravel v6 for an API development and I'm facing a problem. In a post method, when i pass a json object with postman, the $request->getContent() contains a srtring value not a json.
Here is my controller method:
function updateEmployee(Request $request){ $request = $request->getContent(); dd($request); }
api.php:
Route::group(['middleware' => ['auth:api']], function () { Route::get('/employee/{id?}', 'UserController@index')->middleware('scope:admin, normal')->where('id', '[0-9]*'); Route::post('/employee', 'UserController@updateEmployee')->middleware('scope:admin'); });
Request headers are: Authorization: Bearer..., Content-type: Application/json, Accept: Application/json
I tried with json_decode($request->getContent()) but no luck.
any Solution? And thanks.
Please or to participate in this conversation.