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的更多相关文章

  1. AFNetworking request failed unacceptable content type text/html

    今天体验AFNetwork 3.1.0 进行数据解析,但是解析数据控制台一直都输出这样的 error 结果: 于是,照着以前AFN2.+版本的进行设置: 结果发现在新版本的 AFN 上不能设置了.既然 ...

  2. {"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 ...

  3. 遇到问题之“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 ...

  4. No handler for type [text] declared on field [content]

    Install 1.compile checkout ik version respective to your elasticsearch version git checkout tags/{ve ...

  5. JQuery获取input type="text"中的值的各种方式

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  6. AFNetworking遇到错误 Request failed: unacceptable content-type: text/html

    iOS 使用AFNetworking遇到错误 Request failed: unacceptable content-type: text/html 原因: 不可接受的内容类型 “text/html ...

  7. 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 ...

  8. Jsoup问题---获取http协议请求失败 org.jsoup.UnsupportedMimeTypeException: Unhandled content type. Must be text/*, application/xml, or application/xhtml+xml.

    Jsoup问题---获取http协议请求失败 1.问题:用Jsoup在获取一些网站的数据时,起初获取很顺利,但是在访问某浪的数据是Jsoup报错,应该是请求头里面的请求类型(ContextType)不 ...

  9. Jsoup获取部分页面数据失败 org.jsoup.UnsupportedMimeTypeException: Unhandled content type. Must be text/*, application/xml, or application/xhtml+xml.

    用Jsoup在获取一些网站的数据时,起初获取很顺利,但是在访问某浪的数据是Jsoup报错,应该是请求头里面的请求类型(ContextType)不符合要求. 请求代码如下: private static ...

随机推荐

  1. Visio2010建立ER图并直接导出为SQL语句

    Visio2010建立ER图并直接导出为SQL语句 2013年08月20日 ⁄ 综合 ⁄ 共 2581字 ⁄ 字号 小 中 大 ⁄ 评论关闭 建立数据库时我们需要考虑数据之间的关系,为了理清数据之间的 ...

  2. boost 中文编码转换

    Lstring CHanderHttp::CircleDesc(Lint nCurCircle, Lint nMaxCircle,Lint usercount){ std::stringstream ...

  3. 6-11 Level-order Traversal(25 分)

    Write a routine to list out the nodes of a binary tree in "level-order". List the root, th ...

  4. 在Flask中使用Celery的最佳实践

    写在前面 本最佳实践是基于作者有限的经验,欢迎大家共同讨论,可以持续维护此最佳实践.另本文中所使用的环境为Mac&Ubuntu环境,软件版本如下: Celery (4.1.0) Flask ( ...

  5. 详解hdparm: linux下的硬盘测速工具

    hdparm的功能:显示与设定硬盘的参数.hdparm可检测,显示与设定IDE或SCSI硬盘的参数. 语法: hdparm [-CfghiIqtTvyYZ][-a <快取分区>][-A & ...

  6. FastAdmin bootstrap-table 分页手动输入跳转

    FastAdmin bootstrap-table 分页手动输入跳转 Bootstrap-Table (V1.11.0)默认是没有这个功能的,不过作者有写的扩展. https://github.com ...

  7. vs2005+WinCE模拟器+ActiveSync调试WinCE程序

    来源:http://www.cnblogs.com/xjimmyshcn/archive/2011/07/19/2111087.html 一.WinCE 模拟器通过ActiveSync 6.1(即Wi ...

  8. 善待Erlang 代码 -- Xref 实践

    Xref 是一个交叉引用工具,通过分析定义的函数间的调用关系,用于查找函数. 模块. 应用程序和版本之间的依赖关系. 通俗而言,Xref 可以检查代码中函数的调用关系.比如在 moduleA 中的 f ...

  9. python文本挖掘输出权重,词频等信息,画出3d权重图

    # -*- coding: utf-8 -*- from pandas import read_csv import numpy as np from sklearn.datasets.base im ...

  10. Chrome JS断点调试技巧

    Chrome调试折腾记_(2)JS断点调试技巧 技巧一:格式化压缩代码 技巧二:快速跳转到某个断点的位置 技巧三:查看断点内部的作用范围[很实用] 技巧4:监听事件断点 技巧5:DOM及 XHR监听跳 ...