AFNetworking 2.0 获取json数据时,返回 NSLocalizedDescription=Request failed: unacceptable content-type: text/html, 解决方法.

AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];

manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];

1:优先让服务器做好返回类型适配

2:服务器不做的话, 在程序中再加上上面的代码. 把类型加上.

时间: 2024-07-31 04:05:38

AFNetworking 2.0 获取json数据时,返回 NSLocalizedDescription=Request failed: unacceptable content-type: text/html, 解决方法.的相关文章

当获取相似数据时,使用不同方法调用不同sp,但是使用同一个方法去用IIDataReader或者SqlDataReader读取数据时需要判断column name是否存在。

/// <summary> /// Checks clumn Name /// </summary> /// <param name="reader">IDataReader</param> /// <param name="columnName">column name</param> /// <returns>bool</returns> private bool C

nginx下运行php的程序时返回200访问却是空白页问题的解决方法

ngxin中安装php-fpm后,html静态页面没问题,不过,虽然phpinfo页面返回200状态码,但浏览却总是空白页,也没有任何报错. 考虑应该是nginx已经将php页面转移给php处理了,所以问题应该在php的配置上,经过查找,发现需要在nginx中加入一句话:fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name; 安装完nginx后,默认的fastcgi_params配置文件中没有上面这句. 在nginx.

IT忍者神龟之jQuery 使用 $.getJSON() 跨域获取 JSON 数据

假设在服务器上有文件 http://test.unmi.cc/json.php 文件,它的内容为: [代码 1] 01 02 03 04 05 06 07 08 09 10 <?php header('Content-type: application/json'); $user = array (     "name"  => "Unmi",     "blog" => "http://unmi.cc" )

AFNetworking 3.0.4 Error:&quot;Request failed: unacceptable content-type: text/html&quot;

使用AFNetWorking上传内容+参数, 1 NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:@"POST" URLString:@"http://example.com/upload" parameters:nil constructingBodyWithBlock:^(id<AFMultipartFor

AFNetworking报错:(415 Domain=com.alamofire.error.serialization.response Code=-1011 &quot;Request failed: unsupported media type (415)&quot;)

问题? 今天在与后台调接口的时候,遇到一个问题,使用AFNetworking报错,具体如下: Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: unsupported media type (415)" UserInfo={com.alamofire.serialization.response.error.response=<NSHTTPURLResponse:

iOS AFN请求返回错误:&quot;Request failed: unacceptable content-type: text/html&quot;

以前用的好端端的接口,今天访问居然出错了,但是再用浏览器测试,发现可以正常返回数据,甚是奇怪啊. 下面是错误信息: 获取服务器响应出错 error=Error Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unacceptable content-type: text/html" UserInfo=0x7fdfd8729680 {com.alamofire.serializat

Eclipse启动时提示Fail to create the Java Virtual Machine的解决方法

这个错误是Eclipse里面的一个bug,我们通过如下的设置就可以解决它. 打开eclipse安装目录下的eclipse.ini文件: 将其中的256m改为128m,512m改为256m,1024m改为512m即可. 修改后的文件内容如下: -startupplugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar--launcher.libraryplugins/org.eclipse.equinox.launcher.win32

iOS 使用AFNetworking遇到错误 Request failed: unacceptable content-type: text/html

错误日志: Error Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unacceptable content-type: text/html" UserInfo={com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x7f999be478d0> { URL: myUrlX

iOS 使用AFNetworking遇到异常 Request failed: unacceptable content-type: text/html

错误日志是: Error Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unacceptable content-type: text/html" UserInfo={com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x7fc8b970eb70> { URL: http: