AFNetWorking3.1 出现code=-1016错误unacceptable content-type: application/xml"解决办法
来源:互联网 发布:.xyz域名要备案吗 编辑:程序博客网 时间:2024/06/07 13:12
昨天在测试接口时 出现code=-1016错误unacceptable content-type: application/xml"
Error Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unacceptable content-type: application/xml" UserInfo={com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x608000223260>
在网上找了好久都没有这个问题的解决方法,然后花了一上午时间 解决了这个问题
问题描述:
在调试接口时,AF接收 的content type类型
manager.responseSerializer.acceptableContentTypes=[NSSetsetWithObjects:@"text/html",@"text/plain",@"text/xml",@"application/json",@"text/css",nil];
后台给的数据也是@"application/json"格式的,但是用AF请求后显示
显示的是问题是 无法接收content-type 为application/xml的类型
原因描述:
AF无法接收content-type 为application/xml的类型的数据。导致请求失败
需求描述:
在不影响后台大的改动情况下解决请求问题。
解决方案:
开始尝试在AF中添加content-type 为application/xml的类型
[manager.requestSerializer setValue:@"application/xml"forHTTPHeaderField:@"Content-Type"];
但是结果还是一样的。
虽然只是加了这个类型 但是后台那边还是json数据 所以还得加上这一句
[manager.requestSerializer setValue:@"application/json"forHTTPHeaderField:@"Accept"];
问题完美解决。
0 0
- AFNetWorking3.1 出现code=-1016错误unacceptable content-type: application/xml"解决办法
- Code=-1016 “Request failed: unacceptable content-type:null
- Code=-1016 “Request failed: unacceptable content-type: null” UserInfo=0x7a2da380
- Code=-1016 "Request failed: unacceptable content-type: text/html"问题
- 使用AFNetworking 2.0 请求数据时出现错误 Request failed: unacceptable content-type错误解决方法
- 使用AFNetworking 2.0 请求数据时出现错误 Request failed: unacceptable content-type: XXXX 解决方法
- 使用AFNetworking 2.0 请求数据时出现错误 Request failed: unacceptable content-type: text/html 解决方法
- 使用AFNetworking 2.0 请求数据时出现错误 Request failed: unacceptable content-type: text/html 解决方法
- 使用AFNetworking网络请求时出现错误"Request failed: unacceptable content-type: text/html"
- AFNetworking 错误 Request failed: unacceptable content-type: text/plain
- AFNetWorking 错误Request failed: unacceptable content-type: text/html"
- unacceptable content-type: text/plain}
- AFNetWorking出现code=-1016错误解决办法
- AFNetWorking出现code=-1016错误解决办法
- ios AFN 网络请求失败 failed: unacceptable content-type: text/html application/x-javascript
- Request failed: unacceptable content-type: text/plain
- Request failed: unacceptable content-type: text/html
- Request failed: unacceptable content-type: text/html
- UITableViewCell嵌套UIWebView
- 仿天猫 购物车(Android studio 仿天猫 详情页面 添加购物车选择 颜色 尺寸demo)
- 什么是end-to-end神经网络?
- centos下python2升级为python3
- BloomFilter——大规模数据处理利器
- AFNetWorking3.1 出现code=-1016错误unacceptable content-type: application/xml"解决办法
- 用3个label实现scrollView的循环滚动效果
- Bioconductor软件安装与升级
- [ios]顶部添加segment
- Oracle 索引详解
- iOS CGImageRef 对图片进行处理
- 背景建模与前景检测(二)——非参数背景生成
- Learning中的多类分类,多标签分类,多示例学习,多任务学习
- prompt()弹出框内容的传参