is there an easy way to get the http status code in the failure block from AFHTTPClient?

MonkeyBonkey picture MonkeyBonkey · Dec 12, 2011 · Viewed 43.3k times · Source

I see that there is a list of accepted http status codes that I can modify, but I think it would be cleaner if I can get the http status code in the failure block ..

Ok, found the answer with the operation object

failure:^(AFHTTPRequestOperation *operation, NSError *error){ 
        NSLog(@"error code %d",[operation.response statusCode]);
}];

Answer

MonkeyBonkey picture MonkeyBonkey · Dec 12, 2011

Ok, found the answer with the operation object

failure:^(AFHTTPRequestOperation *operation, NSError *error){ 
       NSLog(@"error code %d",[operation.response statusCode]);
}];