afnetworking 请求错误,2023-02-22
Error Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unacceptable content-type: image/gif" UserInfo={NSLocalizedDescription=Request failed: unacceptable content-type: image/gif,
此错误意思是不能接收的返回值类型: image/gif,即服务器返回了一个 image/gif类型的返回值。
出现原因为AFN本身不能接受这种类型,默认接收类型只有application/json,text/json,text/javascript三种。
解决方案:为AFN添加此接收类型:
AFHTTPSessionManager *manager=[AFHTTPSessionManager manager];
manager.reesponseSerializer.acceptableContentTypes = [NSSet setWithObjects: @"application/json", @"text/json", @"text/javascript",@"text/plain",@"image/gif",nil];
参考:https://www.jianshu.com/p/fedda77e27da
3840错误
Error Domain=NSCocoaErrorDomain Code=3840 "JSON text did not start with array or object and option to allow fragments not set."
如上错误提示,是因为服务器返回数据不是正常的json数据,解析不了,