RestKit: Getting HTTP status code when a request fails RestKit: Getting HTTP status code when a request fails ios ios

RestKit: Getting HTTP status code when a request fails


For people using the new version of RESTkit and objectManager, you can fetch the statuscode from the RKObjectRequestOperation:

operation.HTTPRequestOperation.response.statusCode


It turns out that didFailLoadWithError: is not called for HTTP errors. The request:didLoadResponse: method is still called for HTTP errors, so the response (and hence the status codes) are available.


The statusCode property found on RKResponse works for me:

- (void)objectLoader:(RKObjectLoader*)objectLoader didFailWithError:(NSError*)error {    switch ([[objectLoader response] statusCode]) {        case 409:    ...}