前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >iOS AFNetworking “Request failed: unacceptable content-type: text/html”问题

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

作者头像
王大锤
发布2018-05-17 12:13:19
1.6K0
发布2018-05-17 12:13:19
举报
文章被收录于专栏:王大锤

使用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];

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

亲测,好使。

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2015-06-01 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档