{"action":"created","issue":{"url":"https://api.github.com/repos/Alamofire/Alamofire/issues/1431","repository_url":"https://api.github.com/repos/Alamofire/Alamofire","labels_url":"https://api.github.com/repos/Alamofire/Alamofire/issues/1431/labels{/name}","comments_url":"https://api.github.com/repos/Alamofire/Alamofire/issues/1431/comments","events_url":"https://api.github.com/repos/Alamofire/Alamofire/issues/1431/events","html_url":"https://github.com/Alamofire/Alamofire/issues/1431","id":173475667,"number":1431,"title":"validate() \"eats\" response data","user":{"login":"tylerlong","id":733544,"avatar_url":"https://avatars.githubusercontent.com/u/733544?v=3","gravatar_id":"","url":"https://api.github.com/users/tylerlong","html_url":"https://github.com/tylerlong","followers_url":"https://api.github.com/users/tylerlong/followers","following_url":"https://api.github.com/users/tylerlong/following{/other_user}","gists_url":"https://api.github.com/users/tylerlong/gists{/gist_id}","starred_url":"https://api.github.com/users/tylerlong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tylerlong/subscriptions","organizations_url":"https://api.github.com/users/tylerlong/orgs","repos_url":"https://api.github.com/users/tylerlong/repos","events_url":"https://api.github.com/users/tylerlong/events{/privacy}","received_events_url":"https://api.github.com/users/tylerlong/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2016-08-26T15:07:57Z","updated_at":"2016-08-30T22:01:50Z","closed_at":null,"body":"`debugPrint(response)` **without** `validate()`:\r\n\r\n```\r\n[Request]: <NSMutableURLRequest: 0x10040ddd0> { URL: https://platform.devtest.ringcentral.com/restapi/oauth/token }\r\n[Response]: <NSHTTPURLResponse: 0x10025f980> { URL: https://platform.devtest.ringcentral.com/restapi/oauth/token } { status code: 400, headers {\r\n    Connection = \"keep-alive\";\r\n    \"Content-Language\" = en;\r\n    \"Content-Length\" = 83;\r\n    \"Content-Type\" = \"application/json;charset=UTF-8\";\r\n    Date = \"Fri, 26 Aug 2016 15:03:27 GMT\";\r\n    RCRequestId = \"3e87d7de-6b9e-11e6-a8f4-005056bb594d\";\r\n    RoutingKey = SJC11P01PAS01;\r\n    Server = \"nginx/1.8.0\";\r\n    \"Www-Authenticate\" = \"Basic realm=\\\"RingCentral REST API\\\"\";\r\n    \"X-LoadMetric\" = 4;\r\n} }\r\n[Data]: 83 bytes\r\n[Result]: SUCCESS: {\r\n  \"error\" : \"invalid_request\",\r\n  \"error_description\" : \"Unsupported grant type\"\r\n}\r\n[Timeline]: Timeline: { \"Request Start Time\": 493916605.929, \"Initial Response Time\": 493916607.145, \"Request Completed Time\": 493916607.146, \"Serialization Completed Time\": 493916607.146, \"Latency\": 1.217 secs, \"Request Duration\": 1.217 secs, \"Serialization Duration\": 0.000 secs, \"Total Duration\": 1.217 secs }\r\n```\r\n\r\n`debugPrint(response)` **with** `validate()`:\r\n\r\n```\r\n[Request]: <NSMutableURLRequest: 0x10040a5b0> { URL: https://platform.devtest.ringcentral.com/restapi/oauth/token }\r\n[Response]: <NSHTTPURLResponse: 0x100365bd0> { URL: https://platform.devtest.ringcentral.com/restapi/oauth/token } { status code: 400, headers {\r\n    Connection = \"keep-alive\";\r\n    \"Content-Language\" = en;\r\n    \"Content-Length\" = 83;\r\n    \"Content-Type\" = \"application/json;charset=UTF-8\";\r\n    Date = \"Fri, 26 Aug 2016 15:05:49 GMT\";\r\n    RCRequestId = \"9328183a-6b9e-11e6-b36a-005056bb26b9\";\r\n    RoutingKey = SJC11P01PAS01;\r\n    Server = \"nginx/1.8.0\";\r\n    \"Www-Authenticate\" = \"Basic realm=\\\"RingCentral REST API\\\"\";\r\n    \"X-LoadMetric\" = 4;\r\n} }\r\n[Data]: 83 bytes\r\n[Result]: FAILURE: Error Domain=com.alamofire.error Code=-6003 \"Response status code was unacceptable: 400\" UserInfo={StatusCode=400, NSLocalizedFailureReason=Response status code was unacceptable: 400}\r\n[Timeline]: Timeline: { \"Request Start Time\": 493916746.708, \"Initial Response Time\": 493916749.121, \"Request Completed Time\": 493916749.121, \"Serialization Completed Time\": 493916749.122, \"Latency\": 2.413 secs, \"Request Duration\": 2.413 secs, \"Serialization Duration\": 0.001 secs, \"Total Duration\": 2.414 secs }\r\n```\r\n\r\nSo where has the following data gone:\r\n\r\n```\r\n{\r\n  \"error\" : \"invalid_request\",\r\n  \"error_description\" : \"Unsupported grant type\"\r\n}\r\n```\r\n\r\nThe data is very useful message from server. But `validate()` \"eats\" it."},"comment":{"url":"https://api.github.com/repos/Alamofire/Alamofire/issues/comments/243595659","html_url":"https://github.com/Alamofire/Alamofire/issues/1431#issuecomment-243595659","issue_url":"https://api.github.com/repos/Alamofire/Alamofire/issues/1431","id":243595659,"user":{"login":"tobiasoleary","id":1141478,"avatar_url":"https://avatars.githubusercontent.com/u/1141478?v=3","gravatar_id":"","url":"https://api.github.com/users/tobiasoleary","html_url":"https://github.com/tobiasoleary","followers_url":"https://api.github.com/users/tobiasoleary/followers","following_url":"https://api.github.com/users/tobiasoleary/following{/other_user}","gists_url":"https://api.github.com/users/tobiasoleary/gists{/gist_id}","starred_url":"https://api.github.com/users/tobiasoleary/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tobiasoleary/subscriptions","organizations_url":"https://api.github.com/users/tobiasoleary/orgs","repos_url":"https://api.github.com/users/tobiasoleary/repos","events_url":"https://api.github.com/users/tobiasoleary/events{/privacy}","received_events_url":"https://api.github.com/users/tobiasoleary/received_events","type":"User","site_admin":false},"created_at":"2016-08-30T22:01:50Z","updated_at":"2016-08-30T22:01:50Z","body":"Why not use the response passed into the callback method? I don't think it deletes the content in the response just signals their is an error and you can do some extra processing to read the error message in the response' content. \r\n\r\n'''\r\nAlamofire.request(.GET, \"https://httpbin.org/get\", parameters: [\"foo\": \"bar\"])\r\n         .validate()\r\n         .responseJSON { response in\r\n             switch response.result {\r\n             case .Success:\r\n                 print(\"Validation Successful\")\r\n             case .Failure(let error):\r\n                 print(error)\r\n                 print(response) //do extra stuff here. \r\n             }\r\n         }\r\n'''"}}
{"actor":{"display_login":"tobiasoleary"}}