错误日志:

Error Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unacceptable content-type: text/html" UserInfo={com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x7f999be478d0> { URL: myUrlXXXXXX } { status code: 200, headers {

    "Cache-Control" = "no-store, no-cache, must-revalidate, post-check=0, pre-check=0";

    Connection = "keep-alive";

    "Content-Encoding" = gzip;

    "Content-Type" = "text/html; charset=utf-8";

    Date = "Tue, 24 Nov 2015 09:06:04 GMT";

    Expires = "Thu, 19 Nov 1981 08:52:00 GMT";

    Pragma = "no-cache";

    Server = "nginx/1.1.19";

    "Set-Cookie" = "PHPSESSID=qdvtek1k91oeva2u8fats39l93; path=/";

    "Transfer-Encoding" = Identity;

    "X-Powered-By" = "PHP/5.3.10-1ubuntu3.21";

} }, NSErrorFailingURLKey=http:URL: myUrlXXXXXX, com.alamofire.serialization.response.error.data=<7b226572 726f725f 636f6465 223a302c 22657272 6f725f6d 7367223a 22222c22 75706c6f 61645f75 726c223a 22687474 703a5c2f 5c2f7777 772e7467 7370792e 636f6d5c 2f6c6f6f 70657273 5c2f7365 72766572 5c2f6269 6e5c2f63 7573746f 6d65725c 2f75706c 6f61645c 2f373332 31746f75 7869616e 672e6a70 67227d>, NSLocalizedDescription=Request failed: unacceptable content-type: text/html}

 

原因:

不可接受的内容类型 “text/html

解决方案:

AFJSONResponseSerializer.m中,222行左右

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

修改为:

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

iOS 使用AFNetworking遇到错误 Request failed: unacceptable content-type: text/html的更多相关文章

  1. AFNetworking request failed unacceptable content type text/html

    今天体验AFNetwork 3.1.0 进行数据解析,但是解析数据控制台一直都输出这样的 error 结果: 于是,照着以前AFN2.+版本的进行设置: 结果发现在新版本的 AFN 上不能设置了.既然 ...

  2. AFNetworking遇到错误 Request failed: unacceptable content-type: text/html

    iOS 使用AFNetworking遇到错误 Request failed: unacceptable content-type: text/html 原因: 不可接受的内容类型 “text/html ...

  3. iOS 使用AFNetworking遇到异常 Request failed: unacceptable content-type: text/html

    错误日志是: Error Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unac ...

  4. 使用AFNetworking 2.0 请求数据时出现错误 Request failed: unacceptable content-type: text/html 解决方法

    使用AFNetworking 2.0 请求数据时出现错误 Request failed: unacceptable content-type: text/html 解决方法 添加一行 manager. ...

  5. iOS AFNetworking “Request failed: unacceptable content-type: text/html”问题

    使用AFNetworking出现报错: error=Error Domain=com.alamofire.error.serialization.response Code=-1016 "R ...

  6. AFNetworking 遇到错误 Code=-1016 "Request failed: unacceptable content-type: text/plain"

    在开发过程使用了AFNetworking库,版本2.x,先运行第一个官方例子(替换GET 后面的url即可): AFHTTPRequestOperationManager *manager = [AF ...

  7. iOS"Request failed: unacceptable content-type: text/html"

    接口访问出错了,用浏览器测试,发现可以正常返回数据. 下面是错误信息: 获取服务器响应出错 error=Error Domain=com.alamofire.error.serialization.r ...

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

    2015-11-16 10:39:17.235 PullDemo[338:60b] Application windows are expected to have a root view contr ...

  9. NSLocalizedDescription=Request failed: unacceptable content-type: text/html 解决方法

    使用AFNetworking请求一个网站出现了以下错误 Error Domain=com.alamofire.error.serialization.response Code=- "Req ...

随机推荐

  1. android 处理302地址

    最近项目中需要用到重定向下载,所以找了很多的方法都不合适.因为下载的链接并非单纯的地址,而是需要多次转发的, 在下载的时候用的是URL来打开数据流.但是多次测试并不能对多次跳转的链接打开请求.对于30 ...

  2. js实现对json数据的序列化(兼容ie6以上浏览器)

    /** * 增加对JSON数据的序列化方法, * 主要用于IE6.7不支持JSON对象的浏览器 */ var xue = xue || {};xue.json = xue.json || {}; xu ...

  3. 如何使用laravel搭建后台登录系统

    今天想用laravel搭建一个后台系统,就需要最简单的那种,有用户登录系统,试用了下,觉得laravel的用户登录这块做的还真happy.当然,前提就是,你要的用户管理系统是最简单的那种,就是没有用户 ...

  4. 解决AndroidStudio升级版本后恢复初始化设置的问题

    今天把AndroidStudio升级到1.5后发现所有的个性设置全变为初始化了.包括皮肤啊,字体大小.颜色啊,以及快捷键等等.一瞬间就懵了. 升级完后好像有一个弹窗就是提示是否要继续使用之前的配置的, ...

  5. C#--静态成员的生命周期

  6. 视图(View)与部分视图(Partial View)之间数据传递

    写ASP.NET MVC程序,我们经常需要把数据从视图(View)传递至部分视图(Partial View) 或者相反. 今天Insus.NET使用 ControllerBase.TempData 进 ...

  7. 打开Windows10网络发现或是文件打印共享

    新安装的Windows10,已经设置好的目录共享,用户说访问不了.就连管理员的权限使用盘符加"$"也无法访问.原来Windows10默认情况之下,是把网络发现以及文件打印共享关闭的 ...

  8. js带上框架和防止被iframe的代码

    1.永远都会带着框架<script language="JavaScript"><!--if (window == top)top.location.href = ...

  9. .NET Core HtmlAgilityPack HTML解析利器

    最近学习.NET Core ,想把自己之前的一个项目升级到 .NET Core. 发现HtmlAgilityPack 没法进行引用,遂自己做了些修改,可以运行在 .NET Core 中.现在分享出来, ...

  10. jquery基本选择器id

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...