You can also set the Content-Type header in the request if it is missing using middleware:
$app->post('/test', function($request, $response, $args) {
$body = $request->getParsedBody();
// ...
})->add(function($request, $response, $next) {
// set application/json as content-type if no content type is set
if (!$request->hasHeader('Content-Type')) {
$request = $request->withHeader('Content-Type', 'application/json');
}
return $next($request, $response);
});