How can I deal with AFJSONRequestOperation 's response when my service return text/html?

StackOverflow https://stackoverflow.com/questions/8814306

  •  26-10-2019
  •  | 
  •  

Question

I'm new to AFNetWorkingk and my question is when I use AFJSONRequestOperation,my service returned a text/html result! Any one can give me some suggestions?Or other methord to implement this?

Was it helpful?

Solution

Just add text/html to the acceptableContentTypes like this:

[AFJSONRequestOperation addAcceptableContentTypes:[NSSet setWithObject:@"text/html"]];

This is definitely a better option than the one below as you don't need to alter AFJSONRequestOperation.m

OTHER TIPS

Go to AFJSONRequestOperation.m

Add text/html

+ (NSSet *)defaultAcceptableContentTypes {
    return [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", @"text/html", nil];
}

Just a shot in the dark, but try setting the Accept header to application/json for the NSURLRequest, or if that doesn't work, add a .json to the end of the URL.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top