Request failed: unacceptable content-type: text/html using AFNetworking 2.0
This means that your server is sending "text/html"
instead of the already supported types.My solution was to add "text/html"
to acceptableContentTypes
set in AFURLResponseSerialization
class. Just search for "acceptableContentTypes" and add @"text/html"
to the set manually.
Of course, the ideal solution is to change the type sent from the server, but for that you will have to talk with the server team.
Setting my RequestOperationManager
Response Serializer to HTTPResponseSerializer
fixed the issue.
Objective-C
manager.responseSerializer = [AFHTTPResponseSerializer serializer];
Swift
manager.responseSerializer = AFHTTPResponseSerializer()
Making this change means I don't need to add acceptableContentTypes
to every request I make.
I took @jaytrixz's answer/comment one step further and added "text/html" to the existing set of types. That way when they fix it on the server side to "application/json" or "text/json" I claim it'll work seamlessly.
manager.responseSerializer.acceptableContentTypes = [manager.responseSerializer.acceptableContentTypes setByAddingObject:@"text/html"];