AFNetWorking发送post请求,Code=-1016错误
使用AFNetWorking发送post请求时,可能会出现下面Code=-1016问题。打印的error如下:
Error:Error Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unacceptable content-type: text/html" UserInfo=0x7fba3b6f1ba0 {com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x7fba3d8822c0> { URL: http://www.joinbuy.cn/api/login.ios.php?token=15x4874otutDRYxofue8&act=login } { status code: 200, headers {
Pragma = no-cache,
X-Powered-By = PHP/5.2.17,
Server = Apache/2.2.24 (Unix) PHP/5.2.17,
Set-Cookie = deal_city=deleted; expires=Sun, 07-Sep-2014 08:28:41 GMT; path=/api/,
Keep-Alive = timeout=5, max=100,
Connection = Keep-Alive,
Date = Mon, 07 Sep 2015 08:28:42 GMT,
Content-Type = text/html; charset=utf-8,
Content-Length = 46,
Expires = Thu, 19 Nov 1981 08:52:00 GMT,
Cache-Control = no-store, no-cache, must-revalidate, post-check=0, pre-check=0
} }, NSErrorFailingURLKey=http://www.joinbuy.cn/api/login.ios.php?token=15x4874otutDRYxofue8&act=login, com.alamofire.serialization.response.error.data=<7b226d73 67223a22 5c753864 32365c75 35336637 5c753562 63365c75 37383031 5c753935 31395c75 38626566 227d>, NSLocalizedDescription=Request failed: unacceptable content-type: text/html}
AFNetWorking的JSON解析默认库是使用的AFJSONRequestOperation模式,只支持text/json,application/json,text/javascript,所以如果出现code=-1016错误则说明当前的JSON解析模式是text/html,所以要加上这段代码:
[AFJSONRequestOperation addAcceptableContentTypes:[NSSet setWithObject:@"text/html"]];
或者
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];
让他支持text/html模式就可以解决了
AFNetWorking发送post请求,Code=-1016错误的更多相关文章
- AFNetWorking出现code=-1016错误解决办法
报错类似: 2015-12-09 15:58:03.062 Carloans[14328:2300485] Error Domain=com.alamofire.error.serialization ...
- IE 浏览器在地址栏输入中文字符,发送get请求报400错误的问题
因为学校有JavaWeb的课程,所以才接触这方面.最近遇到了个小问题. 先看一段很简单的jsp代码例子 <%@ page language="java" import=&qu ...
- AFNetworking 遇到错误 Code=-1016 "Request failed: unacceptable content-type: text/plain"
在开发过程使用了AFNetworking库,版本2.x,先运行第一个官方例子(替换GET 后面的url即可): AFHTTPRequestOperationManager *manager = [AF ...
- 使用AFNetworking 2.0 请求数据时出现错误 Request failed: unacceptable content-type: text/html 解决方法
使用AFNetworking 2.0 请求数据时出现错误 Request failed: unacceptable content-type: text/html 解决方法 添加一行 manager. ...
- 腾讯云图片鉴黄集成到C# SQL Server 怎么在分页获取数据的同时获取到总记录数 sqlserver 操作数据表语句模板 .NET MVC后台发送post请求 百度api查询多个地址的经纬度的问题 try{}里有一个 return 语句,那么紧跟在这个 try 后的 finally {}里的 code 会 不会被执行,什么时候被执行,在 return 前还是后? js获取某个日期
腾讯云图片鉴黄集成到C# 官方文档:https://cloud.tencent.com/document/product/641/12422 请求官方API及签名的生成代码如下: public c ...
- Django中ajax发送post请求,报403错误CSRF验证失败解决办法
今天学习Django框架,用ajax向后台发送post请求,直接报了403错误,说CSRF验证失败:先前用模板的话都是在里面加一个 {% csrf_token %} 就直接搞定了CSRF的问题了:很显 ...
- Python常见问题 - python3 使用requests发送HTTPS请求报certificate verify failed 错误
当你使用 requests 发送HTTPS请求时 requests.get(url, parmas=parmas, headers=header, cookies=cookie) 出现了以下错误 HT ...
- Ajax发送PUT/DELETE请求时出现错误的原因及解决方案
本文讲什么? 大家应该都知道.在HTTP中,规定了很多种请求方式,包括POST,PUT,GET,DELETE等.每一种方式都有这种方式的独特的用处,根据英文名称,我们能够很清楚的知道DELETE方法的 ...
- Error Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unacceptabl
在使用AFNetworking 2.0 的时候本来一切很顺畅,但是中途遇到几个比较坑的地方 这里分享一下爬坑经历,忘读者不能速爬坑! 在发送请求后,NSURLSessionDataTask一直报错 ...
随机推荐
- ubuntu12.04的NFS配置
安装nfs: #sudo apt-get install nfs-kernel-server ubuntu12.04中的已经是最新版本了,无需安装 打开/etc/exports文件,在末尾加入: /h ...
- C 汇编代码 函数调用指令和栈平衡
1. CALL指令: CALL指令可不是如唤指令,而是子程序调用指令.那么汇编语言中的子程序是什么呢?子程序能被其它程序调用,在实现某种功能后能自动返回到调用程序去的程序.其最后一条指令一定是返回指令 ...
- Air打包exe
1.用flash创建一个airtest.fla,发布目标选择为AIR.ctrl+enter会得到如下文件: 2.把flex sdk的bin中找到adl.exe,复制过来,放置到:项目目录\bin\ad ...
- andorid 自定义view属性declare-styleable
1. reference:参考某一资源ID. (1)属性定义: <declare-styleable name = "名称"> <attr name = &quo ...
- UVALive 6887 Book Club
最大流,有向环覆盖问题. #include<cstdio> #include<cstring> #include<string> #include<cmath ...
- HDU 5480 Conturbatio
区间求和不更新,开个数组记录一下前缀和就可以了 #include<cstdio> #include<cstring> #include<cmath> #includ ...
- 如何让struts2和servlet的共存
如何让struts2和servlet的共存 (2013-08-29 14:07:49) 转载▼ 标签: servlet与struts2共存 同时配置struts2与ser servlet访问不到 分类 ...
- RadioGroup+TabHost
=.= //MainActivity public class MainActivity extends TabActivity implements OnCheckedChangeListener ...
- List转换成DataSet实现代码
public DataSet ConvertToDataSet<T>(IList<T> list) { if (list == null || list.Count <= ...
- Android程序两种退出的方法
两种程序退出的方法: Context的finish()方法: android.os.Process的killProcess()方法:(当程序isRegistered()失败,说明程序被修改过,调用ki ...