iOS"Request failed: unacceptable content-type: text/html"
接口访问出错了,用浏览器测试,发现可以正常返回数据.
下面是错误信息:
获取服务器响应出错 error=Error Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unacceptable content-type: text/html" UserInfo=0x7fdfd8729680 {com.alamofire.serialization.response.error.response= { URL: http://172.16.1.31:7001/itom/getwork } { status code: 200, headers {
"Cache-Control" = "no-cache";
"Content-Type" = "text/html;charset=UTF-8";
Date = "Mon, 24 Nov 2014 03:13:16 GMT";
"Transfer-Encoding" = Identity;
"X-Powered-By" = "Servlet/2.5 JSP/2.1";
} }, NSErrorFailingURLKey=http://172.16.1.31:7001/itom/getwork, com.alamofire.serialization.response.error.data=<5b7b2273 74617475 73223a22 73756363 65737322 2c226d73 67223a22 e799bbe9 9986e688 90e58a9f 227d5d>, NSLocalizedDescription=Request failed: unacceptable content-type: text/html}
I also encountered the same problem.
This means that your server is
sending "text/html"
instead
of the already supported types. After a little search, my solution
was to
add "text/html"
to acceptableContentTypes
set
in AFURLResponseSerialization
class.
Just search for "acceptableContentTypes" and
add @"text/html"
to
the set manually. Of course, the ideal solution will be to change
the tpe from the server, but for that you will hade to talk with
the server team.
I hope this helps you. Best regards and
less bugs as possible in the code.
op.responseSerializer.acceptableContentTypes =
[NSSet setWithObject:@"text/html”];
对应到自己的项目里面,我用的是AFNetworking这套网络请求包,需要改的是:
AFURLResponseSerialization.m文件
223行:
self.acceptableContentTypes =
[NSSetsetWithObjects:@"application/json", @"text/html",@"text/json",@"text/javascript", nil];
加上蓝色部分,其实就是添加一种服务器返回的数据格式。
iOS"Request failed: unacceptable content-type: text/html"的更多相关文章
- AFNetworking request failed unacceptable content type text/html
今天体验AFNetwork 3.1.0 进行数据解析,但是解析数据控制台一直都输出这样的 error 结果: 于是,照着以前AFN2.+版本的进行设置: 结果发现在新版本的 AFN 上不能设置了.既然 ...
- iOS 使用AFNetworking遇到错误 Request failed: unacceptable content-type: text/html
错误日志: Error Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unacc ...
- iOS AFNetworking “Request failed: unacceptable content-type: text/html”问题
使用AFNetworking出现报错: error=Error Domain=com.alamofire.error.serialization.response Code=-1016 "R ...
- iOS 使用AFNetworking遇到异常 Request failed: unacceptable content-type: text/html
错误日志是: Error Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unac ...
- AFNetworking遇到错误 Request failed: unacceptable content-type: text/html
iOS 使用AFNetworking遇到错误 Request failed: unacceptable content-type: text/html 原因: 不可接受的内容类型 “text/html ...
- 使用AFNetworking 2.0 请求数据时出现错误 Request failed: unacceptable content-type: text/html 解决方法
使用AFNetworking 2.0 请求数据时出现错误 Request failed: unacceptable content-type: text/html 解决方法 添加一行 manager. ...
- 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 ...
- AFNetworking 遇到错误 Code=-1016 "Request failed: unacceptable content-type: text/plain"
在开发过程使用了AFNetworking库,版本2.x,先运行第一个官方例子(替换GET 后面的url即可): AFHTTPRequestOperationManager *manager = [AF ...
- NSLocalizedDescription=Request failed: unacceptable content-type: text/html 解决方法
使用AFNetworking请求一个网站出现了以下错误 Error Domain=com.alamofire.error.serialization.response Code=- "Req ...
随机推荐
- 用Python向MySQL数据库插入数据
最近一直在学习MySQL数据库,很感兴趣.这次我做了一个简单的尝试,使用Python3.4与MySQL数据库进行交互,将一份从雪球网上下载的某股票数据上传至MySQL数据库.仅为初学者提供参考,高手请 ...
- EventBus--出现的问题
--- 1 , EventBus收不到消息问题. 项目中遇到的问题,做搜索商品的时候遇到, 1.情况是一个FragmentActivity包含四个碎片Fragment,在FragmentActivit ...
- PL/SQLDeveloper导入导出Oracle数据库方法
前一篇博客介绍了Navicat工具备份Oracle的方法,这篇博客介绍一下使用PL/SQL Developer工具导入导出Oracle数据库的方法. PL/SQL Developer是Oracle数据 ...
- iOS开发 - OC - 实现本地数据存储的几种方式一
iOS常用的存储方式介绍 在iOS App开发过程中经常需要操作一些需要持续性保留的数据,比如用户对于App的相关设置.需要在本地缓存的数据等等.本文针对OC中经常使用的一下存储方式做了个整理. 常用 ...
- Thunderbird扩展
FromToGMAP 1.4 Mail Redirect 0.7.8 MinisizeToTray revived 1.1.2 Nightly Tester Tools 3.7 Thunderbrid ...
- [CF442A] Borya and Hanabi (暴力bitmask)
题目链接:http://codeforces.com/problemset/problem/442/A 题目大意:给你n张卡片,你知道这n张卡片都是什么,但是不知道他们的位置.你每次可以请求朋友指出一 ...
- jquery ajax 返回值 中文时乱码或变成问号解决方法
转载自jquery的 ajax返回值为中文时乱码解决方法 用jquery的ajax,遇到个问题,服务器端从数据库取到的数据没有出现中文乱码问题(日志打出来是没有乱码的),但是异步传到客户的时候却出现了 ...
- C#中操作Word(1)—— word对象模型介绍
一.开发环境布置 C#中添加对Word的支持,只需添加对Microsoft.Office.Interop.Word的命名空间,如下图所示,右键点击“引用”,在弹出的“添加引用”对话框中选中COM标签页 ...
- codis安装手册
本文属原创,转载请注明此信息:http://www.cnblogs.com/robinjava77/p/5465150.html (Robin) codis交流群 240361424 感谢群里各位群 ...
- sqlserver如何关闭死锁进程.
1.首先我们需要判断是哪个用户锁住了哪张表. --查询被锁表 select request_session_id spid,OBJECT_NAME(resource_associated_entity ...