Closed geggleto closed 9 years ago
By default Slim does not parse any other content-type other than the standard form data because PHP does not support it. That means if you attempt to post application/json you will not be able to access the data via $app->request->post();
You must parse the content type yourself. You can either do this on a per-route basis
//For application/json
$data = json_decode($app->request->getBody());
or use some pre-built middleware (https://github.com/slimphp/Slim-Middleware)
New users often seem confused regarding how slim populates params()/get()/post(). Content-Type application/json isn't supported by default, and users have been posting to a route with json data and not receiving anything from request->post().
We should improve the documentation with examples on how to correctly POST application/json data to a slim route, and now to receive that data.