关于Request failed: unacceptable c
2018-07-03 本文已影响60人
追逐_chase
1.关于iOS请求"Request failed: unacceptable content-type: XXXX"
xxxx可能是:@"text/html",@"text/json",@"application/json"等
AFN默认的是下面的:
self.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript",@"text/html", nil];
解决办法:1)manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];
2)AFURLResponseSerialization.m文件
223行:
self.acceptableContentTypes= [NSSetsetWithObjects:@"application/json",@"text/html",@"text/json",@"text/javascript",nil];
加上你要的格式就行,其实就是添加一种服务器返回的数据格式。
2.AFNetworking请求提示Invalid parameter not satisfying: URLString
解决:1)没有转换UTF8
2)网址拼接有吴
3)在info.plist里面加NSAppTransportSecurity key:NSAllowsArbitraryLoads value:yes