Error Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unacceptabl

在使用AFNetworking 2.0  的时候本来一切很顺畅,但是中途遇到几个比较坑的地方

这里分享一下爬坑经历,忘读者不能速爬坑!

在发送请求后,NSURLSessionDataTask一直报错

Error Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unacceptable content-type: text/html"

 AFURLResponseSerialization.m中修改代码就能解决:

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

 修改为

self.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript",@"text/html", nil];
纸上得来终觉浅,绝知此事要躬行
原文地址:https://www.cnblogs.com/asheng/p/5146771.html