报错类似:

2015-12-09 15:58:03.062 Carloans[14328:2300485] Error Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unacceptable content-type: text/html" UserInfo={com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x7fe5ac728b50> { URL: http://api.lizicaifu.com/api.php?s=/Member/index.html&token=e0e9162086738e15a066daed1ff94baa&user_token=c8d353b0008099ba72fbcfea0b16f1c3 } { 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";
Date = "Wed, 09 Dec 2015 07:57:58 GMT";
Expires = "Thu, 19 Nov 1981 08:52:00 GMT";
Pragma = "no-cache";
Server = nginx;
"Transfer-Encoding" = Identity;
"X-Powered-By" = "PHP/5.5.29";
} }, NSErrorFailingURLKey=http://api.lizicaifu.com/api.php?s=/Member/index.html&token=e0e9162086738e15a066daed1ff94baa&user_token=c8d353b0008099ba72fbcfea0b16f1c3, com.alamofire.serialization.response.error.data=<7b227374 61747573 223a2d33 2c22696e 666f223a 225c7538 6266375c 75393163 645c7536 3562305c 75373637 625c7535 66353522 2c226669 72737422 3a6e756c 6c2c226c 61737422 3a224144 38444444 45322d41 4642312d 34343130 2d423536 452d3634 46434331 32303241 4134227d>, NSLocalizedDescription=Request failed: unacceptable content-type: text/html}

1.修改内部文件

AFURLResponseSerialization.m 这个文件找到这句话self.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil]; 然后把 text/html 加进去就可以了! 试试,我就是这么干的。

2.在外面修改

2.0已经对各种方法做了优化,也不需要用AFJSONRequestOperation,2.0已经自带JSON解析。 
你可以用AFHTTPRequestOperationManager解决一切问题,遇到你的这个问题,你可以像这么写: 
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; 
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];//设置相应内容类型 
[manager POST:url parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) { 
} failure:^(AFHTTPRequestOperation *operation, NSError *error) { 
}]; 
2.0会对返回的JSON或者XML自动解析为字典的

AFNetWorking出现code=-1016错误解决办法的更多相关文章

  1. Sub-process /usr/bin/dpkg returned an error code (1)错误解决办法

    之前通过wine安装了一款软件,不经常用,也没有拆卸 可是之后呢,每次更新都要提示更新那个软件,更新的时候又总是找不到更新源 无奈之下,我通过软件中心移除wine,没想到竟然碰到依赖问题,没有拆卸成功 ...

  2. 启动eclipse出现JVM terminated. Exit code=127 错误解决办法

    https://blog.csdn.net/wpzsidis/article/details/72954387 进去第二次又错

  3. MongoDB not authorized for query - code 13 错误解决办法

    跟着教程走完到了鉴权阶段,不加 --auth 登陆正常,但会出现warning :没有鉴权,修改不会生效,此时登陆正常. 但是加上了--auth 启动之后加上密码登陆则无法登陆. 添加用户和鉴权: 先 ...

  4. AFNetWorking发送post请求,Code=-1016错误

    使用AFNetWorking发送post请求时,可能会出现下面Code=-1016问题.打印的error如下: Error:Error Domain=com.alamofire.error.seria ...

  5. centos7 无法启动网络(service network restart)错误解决办法

    centos7 无法启动网络(service network restart)错误解决办法: (以下方法均为网上COPY,同时感谢原博主分享) systemctl status network.ser ...

  6. hadoop 集群常见错误解决办法

    hadoop 集群常见错误解决办法 hadoop 集群常见错误解决办法: (一)启动Hadoop集群时易出现的错误: 1.   错误现象:Java.NET.NoRouteToHostException ...

  7. centos7 无法启动网络(service network restart)错误解决办法(转)

    centos7 无法启动网络(service network restart)错误解决办法:(以下方法均为网上COPY,同时感谢原博主分享) systemctl status network.serv ...

  8. Oracle ORA-01033: ORACLE initialization or shutdown in progress 错误解决办法

    Oracle ORA-01033: ORACLE initialization or shutdown in progress 错误解决办法 登陆数据库时提示 “ORA-01033”错误在命令窗口以s ...

  9. win7 iis7.5 配置错误解决办法

    win7 iis7.5 配置HTTP 错误 404.3 在初次使用IIS7的时候经常遇到的一个错误解决办法1: 找到Visual Studio命令提示工具,运行aspnet_regiis.exe -i ...

随机推荐

  1. 绘制surfaceView 基础类

    public class SurfaceViewTempalte extends SurfaceView implements Callback, Runnable { private Surface ...

  2. SVN中trunk,branches,tags用法详解【转】

    Subversion有一个很标准的目录结构,是这样的.比如项目是proj,svn地址为svn://proj/,那么标准的svn布局是 svn://proj/|+-trunk+-branches+-ta ...

  3. EJB2.0版本的HelloWorld

    EJB2.0版本的HelloWorld   虽然EJB3.1已经出来了,可是EJB2.0的项目还需要维护啊.下面写个简单EJB2.0的HelloWorld程序,练练手.   环境: JBoss 4.0 ...

  4. Openjudge 2.5 6264:走出迷宫

    总时间限制:  1000ms 内存限制:  65536kB 描述 当你站在一个迷宫里的时候,往往会被错综复杂的道路弄得失去方向感,如果你能得到迷宫地图,事情就会变得非常简单. 假设你已经得到了一个n* ...

  5. CloudFoundry命令行和Kubernetes命令行的Restful API消费方式

    先说CloudFoundry的命令行工具CLI.我们在CloudFoundry环境下工作,第一个使用的命令就是cf login. 如果在环境变量里维护CF_TRACE的值为true: 则我们能发现,诸 ...

  6. Caused by: java.lang.IllegalStateException: Ambiguous mapping. Cannot map 'userController' method

    在使用SpringMVC的时候遇到了这个问题 问题原因:  在指定方法所对应的url地址的时候重复了, 也就是@RequestMapping("url")中, 两个方法使用了同一个 ...

  7. How to debug add-ins for arcgis

    Debugging add-ins To debug an add-in, follow these steps: Confirm that the add-in is deployed to the ...

  8. XML解析(一) DOM解析

    XML解析技术主要有三种: (1)DOM(Document Object Model)文档对象模型:是 W3C 组织推荐的解析XML 的一种方式,即官方的XML解析技术. (2)SAX(Simple ...

  9. ios之NSURLRequest&NSURLConnection

    网络编程中一般都是经过  请求--->连接--->响应   (request  -->  connection  -->  response)这个过程. 一般的步骤是这样的: ...

  10. NSLayoutConstraint.constraintsWithVisualFormat详解,以及AlignAllCenterY

    NSLayoutConstraint.constraintsWithVisualFormat详解,以及AlignAllCenterY 转载2015-07-08 18:02:02 鉴于苹果官方文档的解释 ...