首页 > 移动平台 > 详细

iOS AFNetworking “Request failed: unacceptable content-type: text/html”问题

时间:2015-06-02 00:21:15      阅读:7271      评论:0      收藏:0      [点我收藏+]

使用AFNetworking出现报错:

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";
å

 

 

 

解决方法:

全工程搜索AFURLResponseSerialization.m文件

修改223行:

self.acceptableContentTypes = [NSSetsetWithObjects:@"application/json", @"text/html",@"text/json",@"text/javascript", nil];

加上蓝色部分,其实就是添加一种服务器返回的数据格式。

亲测,好使。

iOS AFNetworking “Request failed: unacceptable content-type: text/html”问题

原文:http://www.cnblogs.com/6duxz/p/4545277.html

(0)
(7)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!