The answer was simple - operation.responseObject
in failure callback contains json data as well. Sweet ^.^
AFNetworking 2 - get error json body [duplicate]
-
21-07-2023 - |
Question
I'm using latest AFNetworking for my app which speaks with REST API server.
When I get some 500
error from it with JSON body something like
{ "message": "my error message" }
,
I cannot retrieve this message from NSError
which lib responds to me:
[api setupUser:data success:^(AFHTTPRequestOperation *operation, id responseObject) {
// some success handle
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
// cannot get json response of error :(
}];
How do you workaround it?
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow