I'm using Slim v4
for a little arduino components API. When I do a POST
call over my controller, I get an empty request body without the parameters I sent to it.
In code below, in $parameters
variable I have a NULL.
public function __invoke(
ServerRequestInterface $request,
ResponseInterface $response
) : ResponseInterface {
$ret = [
'success' => false
];
$parameters = (array) $request->getParsedBody();
}
I'm using postman
for doing CURL
requests, but also this error shows up when I use curl
in bash.
The code below is the way I register a new API call.
$application = AppFactory::create();
$application->group('/ambient', function(RouteCollectorProxy $routeCollector) {
$routeCollector
->post('/register', RegisterAmbientController::class)
->setName('register-ambient');
});
You can also see the full code in my github:
https://github.com/JasterTDC/ardu-component/tree/feature/register-temp-humidity
Thanks in advance !
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…