Improvements to Response Descriptor Errors

One of the most significant improvements in RestKit 0.20 is the addition of the RKRequestDescriptor and RKResponseDescriptor classes for configuring how object mappings bind to the HTTP request and response cycle.

RKResponseDescriptor at last brings simple, elegant support for both key path addressable and URL addressable mappings. When properly configured, they are very easy to reason about and straightforward to predict.

Unfortunately, when they fail to match your responses it can be somewhat maddening. To properly match, the base URL, requested URL path, and the response descriptors must all be in harmony. The heaviest amount of support traffic on both Stack Overflow and the RestKit Google group lately has been surrounding issues with response descriptors failing to match.

Today I sat down and spent an hour improving this situation. As of commit 
d79dec1, RestKit will now output a very thorough description under the NSLocalizedFailureReasonErrorKey of why all of the response descriptors failed to match in the event that none matched your response.

Here’s an example from the unit tests showing the various types of mismatches:

A 200 response was loaded from the URL ‘’, which failed to match all (3) response descriptors:

<RKResponseDescriptor: 0xeb32450 baseURL= pathPattern=/users statusCodes=200> failed to match: response path ‘users’ did not match the path pattern ‘/users’.

<RKResponseDescriptor: 0xeb32530 baseURL= pathPattern=/users statusCodes=200> failed to match: response URL ‘’ is not relative to the baseURL ‘’.

  <RKResponseDescriptor: 0xeb32610 baseURL= pathPattern=users statusCodes=202-206> failed to match: response status code 200 is not within the range 202-206

Hopefully this will it very easy to spot mismatches in the configuration and fix them quickly.

This change is available on the development branch now and will be released with RestKit 0.20-pre3 shortly.