错误日志:

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. Hadoop官方文档翻译——YARN Architecture(2.7.3)

    The fundamental idea of YARN is to split up the functionalities of resource management and job sched ...

  2. 云计算之路-阿里云上:Web服务器遭遇奇怪的“黑色30秒”问题

    今天下午访问高峰的时候,主站的Web服务器出现奇怪的问题,开始是2台8核8G的云服务器(ECS),后来又加了1台8核8G的云服务器,问题依旧. 而且3台服务器特地使用了不同的配置:1台是禁用了虚拟内存 ...

  3. [Python] Ubuntu12.04LTS

    Ubuntu 12.04LTS中缺省安装了Python2.7.3. python -h 查看可用选项 python -V 查看Python版本 下面写个简单的测试程序: 新建HelloWorld.py ...

  4. [Java 基础]数组

    数组初始化 定义数组语法格式 定义数组有两种方式,如下两种格式是等价的: int[] a1; int a1[];  注:在C/C++中,不支持第一种格式.但是,推荐使用这种方式,因为这样似乎更合理,声 ...

  5. CSS3 介绍

    什么是CSS3 CSS即层叠样式表(Cascading Stylesheet). 在网页制作时采用CSS技术,可以有效地对页面的布局.字体.颜色.背景和其它效果实现更加精确的控制. 只要对相应的代码做 ...

  6. Ubuntu14.04安装JDK

    下载oracle jdk包 从oracle官网下载jdk包,请选择Linux的tar包: 如果想使用命令行下载工具进行下载,可以先获得下载地址,然后运行curl进行下载: curl -L -O -H ...

  7. LeetCode - 49. Group Anagrams

    49. Group Anagrams Problem's Link ------------------------------------------------------------------ ...

  8. C语言学习007:重定向标准输入和输出

    先来完成一个将输入数据转换成json格式输出的小任务 #include <stdio.h> int main(){ float latitude; float longtitude; ]; ...

  9. winform水平滚动条联动panel

    需求: 滚动滚动条时显示pnlBack里面的button 文本框里输入数字,改变每行显示的按钮数 源码如下: /// <summary> /// 窗体加载 /// </summary ...

  10. Windows Server 2012 配置多用户远程桌面

    前段时间因为需要多用户同时远程连接 windows server 2012,但找了半天也没找到远程桌面管理,最后从搜索中找到如下方法,经测试可行! 打开注册表,进入路径: [HKEY_LOCAL_MA ...