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

来源:互联网 发布:人工智能 百度网盘 编辑:程序博客网 时间:2024/05/21 11:43
在使用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];

 

0 0
原创粉丝点击