RestKit: Getting HTTP status code when a request fails

I’m using RestKit in an iOS app and I need to have special handling for certain HTTP error codes. How can the the response HTTP status code be checked inside of request:didFailLoadWithError:? Is there some entry in the userInfo dictionary of the NSError?

I couldn’t find anything in the RKRequestDelegate documentation.

  • Are the sorting algorithms used by NSArray stable sorts?
  • Capture Wi-Fi network changing event in iOS
  • Can I send an image with Apple's Push Notification Service?
  • Removing multiple spaces in NSString
  • Xcode 7.2 no matching provisioning profiles found
  • Difference between NSCalendarUnitWeekOfYear & NSCalendarUnitWeekOfMonth
  • Here’s the interface for the delegate method:

    - (void)request:(RKRequest *)request didFailLoadWithError:(NSError *)error

    3 Solutions Collect From Internet About “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:


    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: