I'm currently developing a REST API with the Slim framework.
To test my API I'm using postman but I can't retrieve the status code sent by the slim method:
$response->withJson($data, $status, $encodingOptions)
$slimApp->post('/v1/users', function(Request $request, Response $response) {
echo $response->withJson(['data' => 'something'], 400);
});
I set the status code to '400' but postman keep saying it's a '200' status.
The header sent by slim is :
HTTP/1.1 400 Bad Request
Content-Type: application/json;
charset=utf-8
The fact is that, I can manually verify the code status with the header, but I would like to verify it through the collection runner of postman.
Do you have any idea about this postman behavior ?
Relating to this issue in the slim github repository you have to return the response, instead of echoing it:
$slimApp->post('/v1/users', function(Request $request, Response $response) {
return $response->withJson(['data' => 'something'], 400);
});