How can I deal with AFJSONRequestOperation 's response when my service return text/html?
-
26-10-2019 - |
题
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?
解决方案
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
其他提示
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.
不隶属于 StackOverflow