错误日志:

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. Moon River

    读书笔记系列链接地址http://www.cnblogs.com/shoufengwei/p/5714661.html.        昨晚无意中听到了一首英文歌曲,虽不知其意,但是瞬间就被优美的旋律 ...

  2. CSS选择器的一些记录

    选择器 例子 例子描述 CSS .class .intro 选择 class="intro" 的所有元素. 1 #id #firstname 选择 id="firstna ...

  3. PhotoShop常用快捷键

    Photoshop常用快捷键: 图01 图02 图03 图04 图05 快捷键 PS快捷键是Photoshop为了提高绘图速度定义的快捷方式,它用一个或几个简单的字母来代替常用的命令. 多种工具共用一 ...

  4. exp/imp 参数说明,中英对照

    在任意可用exp/imp(导出/导入)命令的主机上,都可以通过exp/imp help=y查看所有的参数说明. 1.exp参数说明 2.imp参数说明 3.exp参数说明(中文) 4.imp参数说明( ...

  5. 再次用CodeIgniter实现简易blog

    天变冷了,人也变得懒了不少,由于工作的需要,最近一直在学习CodeIgniter(CI)框架的使用,没有系统的从PHP基本语法学起,在网上靠百度谷歌,东拼西凑的实现了一些简单的功能.所以,老PHPer ...

  6. Git的奇技淫巧🙈

    Git的奇技淫巧

  7. 创建数据库和表相关的SQL语句

    SQL server注释语句有两种: 一种是单行注释,一种是多行注释. ******************** 单行注释用:--注释一行内容 多行注释用:/* *注释 *多行内容 */ 创建数据库: ...

  8. [Java 进阶]异常

    异常:程序在运行过程中发生由于硬件设备问题.软件设计错误等导致的程序异常事件. 世上没有百分之百完美的程序.程序总难免存在各式各样的问题.所以,程序中添加对于错误的处理机制是十分有必要的.这就好比人多 ...

  9. 解决 DotNetCore.1.0.1-VS2015Tools.Preview2.0.3.exe 在VS2015 Update3 安装失败的问题

    今天抽空升级VS2015 Update3. 在安装DotNetCore.1.0.1-VS2015Tools.Preview2.0.3.exe 时报错了,看了错误日志 显示: 看到我标红的两个地方,那么 ...

  10. [Asp.net 5] DependencyInjection项目代码分析4-微软的实现(2)

    在 DependencyInjection项目代码分析4-微软的实现(1)中介绍了“ServiceTable”.“ServiceEntry”.“IGenericService”.“IService”. ...