Reputation: 31
I'm trying to build a rest API with the slim framework, however I have some trouble with the put
request which doesn't allow GetParsedBody
, I looked a lot on internet but didn't find usable method, the only one who worked is :parse_str($request->getBody()->getContents(), $icone);
where icone is the variable to return.
Here is my code if you want to see it but i don't matter for this question, thank you for your time !
$app->put('/{id}', function($request, $response, $args) use ($app){
$boucle = array();
$route = $request->getAttribute('route');
$courseId = $route->getArgument('id');
parse_str($request->getBody()->getContents(), $icone);
return $response->withJson($icone);
});
Upvotes: 0
Views: 1214
Reputation: 542
Try this
$route=$req->getParsedBodyParam('route');
$id=$req->getParsedBodyParam('id');
Upvotes: 2