AFNetworking 3.0 Code=-1016 错误解决

2016-11-08  本文已影响615人  晓飞90
-[NetworkEngine doPost:params:handler:errorHandler:]_block_invoke.101 [Line:121]sf = Error Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unacceptable content-type: application/json" UserInfo={com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x13f091530> { URL: http://testapp.chekuangxian.com/report/selectCars } { status code: 200, headers {
    Connection = "keep-alive";
    "Content-Encoding" = gzip;
    "Content-Type" = "application/json;charset=utf-8";
    Date = "Tue, 08 Nov 2016 03:18:52 GMT";
    Server = "nginx/1.6.2";
    "Transfer-Encoding" = Identity;
    Vary = "Accept-Encoding";
} }, NSErrorFailingURLKey=http://testapp.chekuangxian.com/report/selectCars, com.alamofire.serialization.response.error.data=<7b227265 74436f64 65223a22 2d31222c 22657272 6f724d73 67223a22 746f6b65 6ee99d9e e6b395e6 8896e8bf 87e69c9f 222c2276 616c7565 223a2222 7d>, NSLocalizedDescription=Request failed: unacceptable content-type: application/json}
self.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript",@"text/html", nil];

没办法就去看了一下后台大哥写的代码,后台返回的类型是application/json,让他改成text/html后就出现了下面的错误

Error:Error Domain=NSCocoaErrorDomain Code=3840 "JSON text did not start with array or object and option to allow fragments not set." UserInfo={NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}
sessionManager.responseSerializer = [AFHTTPResponseSerializer serializer]
上一篇 下一篇

猜你喜欢

热点阅读