Set the accepted content types you want on the serialiser with acceptableContentTypes
:
AFJSONResponseSerializer *serializer = [AFJSONResponseSerializer serializer];
serializer.acceptableContentTypes = [NSSet setWithArray:@[@"text/plain", @"text/html"]];
[op setResponseSerializer:serializer];
From the docs:
By default,
AFJSONSerializer
accepts the following MIME types, which includes the official standard, application/json, as well as other commonly-used types:application/json text/json
You don't have to use AFJSONResponseSerializer
, as you can create your own serializer as long as it conforms to the AFURLResponseSerialization
protocol.
If you have JSON
responses but XML
error responses, you could just subclass AFHTTPResponseSerializer
and do your own processing in there.
You could also use AFCompoundResponseSerializer
to parse different response types just going through the serializers you give it.