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

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

  •  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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top