REST API를 사용하는 iOS 프로젝트에 AFNetworking 2를 사용하고 있습니다. 요청이 실패하면 신체 반응을 얻을 수 없습니다.AFNetworking 2 - 요청이 실패하면 응답 본문이 없습니다.
이 SO answer은 userInfo
사전에서 검색 할 수 있음을 확인했습니다. 불행히도 제 경우에는 응답 본문 userInfo
사전에 NSLocalizedRecoverySuggestion
키 - 값을 가져 오지 못했습니다. 대신 AFNetworkingOperationFailingURLResponseErrorKey
키가 표시됩니다. 당신은 헤더에서, 내가 지금이 다른 answer 중 하나에는 적용되지 않습니다 "Content-Type" = "application/json; charset=utf-8";
무엇입니까 볼 수 있듯이
내 NSError
로그
Error Domain=AFNetworkingErrorDomain Code=-1011 "Request failed: bad request (400)" UserInfo=0xbe471a0 {NSErrorFailingURLKey=http://***.com/api/users, AFNetworkingOperationFailingURLResponseErrorKey=<NSHTTPURLResponse: 0xbc60e80> { URL: http://***.com/api/users } { status code: 400, headers {
Connection = "keep-alive";
"Content-Length" = 85;
"Content-Type" = "application/json; charset=utf-8";
Date = "Thu, 24 Apr 2014 21:36:57 GMT";
"X-Powered-By" = Express;
} }, NSLocalizedDescription=Request failed: bad request (400)}
입니다.
사실 Postman의 신체 반응은 다음과 같습니다
{"errorCode":100,"description":"There is already a registered user with that email."}
백엔드는 노드 + Express에서 자신에 의해 구현됩니다. 백엔드 개발 경험이별로 없기 때문에 내가 누락되거나 변경 될 수있는 무언가가있을 수 있습니다.
응답 본문을 가져 오지 못하는 이유가 누구인지 알고 있습니까? userInfo
?