How to retrieve the HTTP code using postman from a Json slim response?
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 ?
在slim github仓库中涉及到这个问题,你必须返回响应,而不是回应它:
$slimApp->post('/v1/users', function(Request $request, Response $response) {
return $response->withJson(['data' => 'something'], 400);
});
链接地址: http://www.djcxy.com/p/48528.html
上一篇: CouchDB:创建文档的工作流程?