My server (CakePHP) responds like this:
$this->response->statusCode('400'); $this->response->type('json'); $this->response->body(json_encode(array('message' => 'Bookmark already exists')));
Postman's output looks like you expected:
{"message": "Bookmark already exists"}
The problem is that I cannot find a way to access this message from the failure handler (Alamofire 3.1.3 + SwiftyJSON 2.3.2)
Alamofire.request(.POST... .validate() .responseJSON { response in switch response.result { case .Success(_): // All good case .Failure(let error): // Status code 400 print(response.request) // original URL request print(response.response) // URL response print(response.data) // server data print(response.result)
I cannot find a way to drop the response.data for JSON as I just get nil and the result returns only FAILURE.
Is there a way to access this server message from a failure handler?
source share