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. python 读写三菱PLC数据,使用以太网读写Q系列,L系列,Fx系列的PLC数据

    本文将使用一个gitHub开源的组件技术来读写三菱的plc数据,使用的是基于以太网的TCP/IP实现,不需要额外的组件,读取操作只要放到后台线程就不会卡死线程,本组件支持超级方便的高性能读写操作 gi ...

  2. 详解UML图之类图 (转)

    原址: https://www.jianshu.com/p/4cd95d4ddb59 2.  怎么画类图?用什么工具? 使用工具:Visio或者processon在线作图 在类图中一共包含了以下几种模 ...

  3. CF1082G:G. Petya and Graph(裸的最大闭合权图)

    Petya has a simple graph (that is, a graph without loops or multiple edges) consisting of n n vertic ...

  4. BZOJ3211: 花神游历各国(线段树)

    3211: 花神游历各国 Time Limit: 5 Sec  Memory Limit: 128 MBSubmit: 5692  Solved: 2114[Submit][Status][Discu ...

  5. Map集合统计字母次数

    Map集合练习:"asfefxAAcf34vrfdfse2-2asd--wdd"获取该字符串中,每一个字母出现的次数要求打印的结果是:a(2)c(1)...;思路:对结果分析发现, ...

  6. BZOJ3270: 博物馆【概率DP】【高斯消元】

    Description 有一天Petya和他的朋友Vasya在进行他们众多旅行中的一次旅行,他们决定去参观一座城堡博物馆.这座博物馆有着特别的样式.它包含由m条走廊连接的n间房间,并且满足可以从任何一 ...

  7. CentOS7 tomcat systemctl脚本

    1,centos7 使用 systemctl 替换了 service命令 参考:redhat文档: https://access.redhat.com/documentation/en-US/Red_ ...

  8. sorting--codility

    lesson 6: sorting 1. Distinct 2. Triangle 2. MaxProductOfThree 4. NumberOfDiscIntersections lesson 6 ...

  9. SQL中禁用trigger

    SQL中禁用所有trigger   编写人:CC阿爸 2014-6-15 在日常SQL数据库的操作中,如何快速的禁用所有trigger? --禁用某个表上的所有触发器 ALTER  

  10. WeX5 苹果APP打包教程

    来源:http://docs.wex5.com/app-packing/ WeX5平台App打包教程 WeX5是前端快速开发框架,可开发跨端运行应用,是移动App/微信/WebApp开发利器,一次开发 ...