I had that same issue yesterday.
make sure that your php.ini contains
enable_post_data_reading = On
and then use ved's method to read and get the POST data, because php doesn't recognize json-post, as it's used to receive a "application/x-www-form-urlencoded" Content-Type.
if you haven't enabled that php.ini value, then all the POST routes comes in as GET and you're not able to fetch its payload.
I basically used this snippet for automatically populating the POST array:
require('vendor/autoload.php');
/** @var \Base $f3 */
$f3 = \Base::instance();
// transform json POST body data
if ($f3->VERB == 'POST'
&& preg_match('/json/',$f3->get('HEADERS[Content-Type]')))
{
$f3->set('BODY', file_get_contents('php://input'));
if (strlen($f3->get('BODY'))) {
$data = json_decode($f3->get('BODY'),true);
if (json_last_error() == JSON_ERROR_NONE)
$f3->set('POST',$data);
}
}
$f3->run();