AFJSONRequestOperation failing because webservice returns JSON with content type text/html

afnetworking, ios, objective-c

Solution

Yes it is possible, AFNetworking supports adding acceptable content types. In the init method of your AFHTTPClient subclass do the following:

[AFJSONRequestOperation addAcceptableContentTypes:[NSSet setWithObjects:@"text/html", nil]];

I have had the same problem with my app and this made it work.

Problem

I am trying to update my app to use AFNetworking but the webservice I need to work with returns JSON as text/html which is breaking when I try and use AFJSONRequestOperation: ``` Expected content type {( "text/json", "application/json", "text/javascript" )}, got text/html ``` Is there anyway to override this in AFNetworking so I can accept the text/html?

Original source