0

We are using cocoapods in our project

pod 'AFNetworking', '~> 4.0.1'

AFURLResponseSerialization has the below acceptableContentTypes

- (instancetype)init {
    self = [super init];
    if (!self) {
        return nil;
    }

    self.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];

    return self;
}

API is getting failed with the error Request failed: unacceptable content-type: text/html

I have tried to set content type as text/HTML to the request, but it's not working.

[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];

Is there any chance to add "text/html" to the acceptable content types.

Any help will be appreciated. Thanking you in advance.

  • Add it to the currently `acceptableContentTypes`. At some point, you do something.responseSerializer = somethingElse, no? In that somethingElse, set its own `acceptableContentype`. Like this https://stackoverflow.com/a/26119980/1801544 – Larme Mar 25 '21 at 16:52
  • Hi @Larme , Thanks for the answer. Currently we passing only via NSUrlrequest "application/json". I added to it but didnt work. We are not managing anything from our code. We are just forming request and passing it on. something.responseSerializer = somethingElse . This code is also in pod only. – Maneesh Aucharla Mar 26 '21 at 02:55
  • What's your request code? You don't use a `AFURLSessionManager` at all? – Larme Mar 26 '21 at 08:55

0 Answers0