iOS"Request failed: unacceptable content-type: text/html"
2016-04-14 18:20
411 查看
测试好端端的接口 出错了,但是再用浏览器测试,发现可 以正常返回数据,甚是奇怪啊。 下面是错误信息: 获取服务器响应出错 error=Error Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unacceptable content-type: {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 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”];
self.acceptableContentTypes = [NSSetsetWithObjects:@"application/json", @"text/html",@"text/json",@"text/javascript", nil]; 其实就是添加一种服务器返回的数据格式。
相关文章推荐
- quicksqlite简介
- GUI控键之Label,Button,TextFild及PasswordField
- iOS UIButton上同时加图片和标题,设置偏移
- Volley之 JsonRequest 解析JSON 数据
- UIView 中常见的方法总结
- UIMenuController
- arduino随笔(3)
- 【Uiautomator】手机系统测试----图库
- [Unit Testing] Angular Test component with required
- 转SSIS 2012 pass values from child package to parent with project deployment model
- [UIImageView sd_setImageWithURL:placeholderImage:]: unrecognized selector sent to instance
- 【转】工作队列(workqueue)
- 为什么要用Message Queue
- Longest Consecutive Sequence
- 创建UITextField对象
- SVN: 更新出错Description : The working copy is locked due to a previous error
- UIView的setNeedsDisplay和setNeedsLayout方法区别
- CUICatalog: Invalid asset name supplied:
- 使用uiautomatorviewer获取android apk的元素
- Tableview快速上手(方法注释到位哦)