AFNetworking 不支持 text/plain,unacceptable content-type: text/plain
1、 用AFNetworkingPOST传递参数(获取微博的accessToken)的时候,具体代码如下:
AFHTTPSessionManager *session = [AFHTTPSessionManager manager];
NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
parameters[@"client_id"] = @"";
parameters[@"client_secret"] = @"09c7301ac169533b1f2440a018e6ce93";
parameters[@"grant_type"] = @"authorization_code";
parameters[@"code"] = code;
parameters[@"redirect_uri"] = @"http://www.baidu.com"; [session POST:@"https://api.weibo.com/oauth2/access_token" parameters:parameters progress:^(NSProgress * _Nonnull uploadProgress) { } success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
NSLog(@"%@", responseObject);
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
NSLog(@"%@",error);
}];
报,警告:"Request failed: unacceptable content-type: text/plain"
百度出来说AFNetworking不支持text/plain,这个格式。
解决办法1.:在头文件"AFURLResponseSerialization.m"的如下地方添加text/plain就行了。问题解决。
self.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/plain",@"text/json", @"text/javascript", nil];
解决办法2.添加一句代码:
session.responseSerializer = [[AFCompoundResponseSerializer alloc] init];
问题也能解决,但是这样返回的的data数据,还是需要自己转成需要的格式。
AFNetworking 不支持 text/plain,unacceptable content-type: text/plain的更多相关文章
- AFNetworking request failed unacceptable content type text/html
今天体验AFNetwork 3.1.0 进行数据解析,但是解析数据控制台一直都输出这样的 error 结果: 于是,照着以前AFN2.+版本的进行设置: 结果发现在新版本的 AFN 上不能设置了.既然 ...
- {"timestamp":"2019-11-12T02:39:28.949+0000","status":415,"error":"Unsupported Media Type","message":"Content type 'text/plain;charset=UTF-8' not supported","path":&quo
在Jmeter运行http请求时报错: {"timestamp":"2019-11-12T02:39:28.949+0000","status&quo ...
- 遇到问题之“postman报Unsupported Media Type: Content type 'text/plain;charset=UTF-8' not supported”
postman报Unsupported Media Type: Content type 'text/plain;charset=UTF-8' not supported postman之所以报Uns ...
- No handler for type [text] declared on field [content]
Install 1.compile checkout ik version respective to your elasticsearch version git checkout tags/{ve ...
- JQuery获取input type="text"中的值的各种方式
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- AFNetworking遇到错误 Request failed: unacceptable content-type: text/html
iOS 使用AFNetworking遇到错误 Request failed: unacceptable content-type: text/html 原因: 不可接受的内容类型 “text/html ...
- Chrome 报 Resource interpreted as Script but transferred with MIME type text/plain 警告的解决办法
http://www.2cto.com/os/201312/262437.html 安装了VS2012之后,chrome在加载页面的时候会报 Resource interpreted as Scrip ...
- Jsoup问题---获取http协议请求失败 org.jsoup.UnsupportedMimeTypeException: Unhandled content type. Must be text/*, application/xml, or application/xhtml+xml.
Jsoup问题---获取http协议请求失败 1.问题:用Jsoup在获取一些网站的数据时,起初获取很顺利,但是在访问某浪的数据是Jsoup报错,应该是请求头里面的请求类型(ContextType)不 ...
- Jsoup获取部分页面数据失败 org.jsoup.UnsupportedMimeTypeException: Unhandled content type. Must be text/*, application/xml, or application/xhtml+xml.
用Jsoup在获取一些网站的数据时,起初获取很顺利,但是在访问某浪的数据是Jsoup报错,应该是请求头里面的请求类型(ContextType)不符合要求. 请求代码如下: private static ...
随机推荐
- HTML5和XHTML的区别
既然被问到了HTML5和XHTML的区别,那我就在这里给大家分享一些我个人的理解,同时我也觉得从他们的来源上讲,他们藏着一个有趣的故事. 首先认识三个组织,IETF (Internet Enginee ...
- XMU 1246
http://acm.xmu.edu.cn/JudgeOnline/problem.php?id=1246 求区间内素数个数,经典问题,区间长度10^6,数的取值最多能到10^12(此题范围稍小) 用 ...
- 前端打印日志到localStroge并导出
interface LogEntry { data: any time: Date } export class PersistantLog { //最大条数 maxEntries = 3000; i ...
- opencv之访问图像像素
访问像素的三种方法 ①指针访问:最快 ②迭代器iterator:较慢,非常安全,指针访问可能出现越界问题 ③动态地址计算:更慢,通过at()实现.适用于访问具体某个第i行,j列的像素,而不适用遍历像素 ...
- CF1143C Queen
CF1143C Queen 开始想大力维护 \(bfs\) 序+数据结构解决,但 \(bfs\) 序的变化不太好推. 换了一个思路,注意到删除一个点后,原来可以被删除的点仍然可以被删除,原来不能被删除 ...
- iframe相关知识
iframe 不带边框的iframe因为能和网页无缝的结合从而不刷新页面的情况下更新页面的部分数据成为可能,可是 iframe的大小却不像层那样可以“伸缩自如”,所以带来了使用上的麻烦.一般通过百分比 ...
- python print的用法
第一种是格式化的 strHello = "the length of (%s) is %d" %('Hello World',len('Hello World')) import ...
- List用法与介绍
泛型的好处:它为使用c#语言编写面向对象程序增加了极大的效力和灵活性.不会强行对值类型进行装箱和拆箱,或对引用类型进行向下强制类型转换,所以性能得到提高. 性能注意事项:在决定使用ILis ...
- Python 数据处理库 pandas
核心数据结构 pandas最核心的就是Series和DataFrame两个数据结构. 名称 维度 说明 Series 1维 带有标签的同构类型数组 DataFrame 2维 表格结构,带有标签,大小可 ...
- oracle事务知识点小结
DML语句流程 1 获取事务锁和ITL2 锁定候选行3 生成redo4 生成undo5 生成redo record写入log buffer并更改数据块 事务提交1 分配SCN2 更新事务表,将事务槽状 ...