首先说下解决办法
1: code=1016
错误提示:
Error Domain=AFNetworkingErrorDomain Code=-1016 "Request failed: unacceptable content-type: text/plain"
UserInfo={AFNetworkingOperationFailingURLResponseErrorKey={ URL: http://139.196.23.39:8081/api/userAccountInfo.asmx/userReg } { status code: 200, headers {
"Cache-Control" = "private, max-age=0";
"Content-Length" = 2;
Date = "Thu, 24 Mar 2016 09:43:41 GMT";
Server = "Microsoft-IIS/8.5";
"X-AspNet-Version" = "4.0.30319";
"X-Powered-By" = "ASP.NET";
} }, NSLocalizedDescription=Request failed: unacceptable content-type: text/plain, NSErrorFailingURLKey=http://139.196.23.39:8081/api/userAccountInfo.asmx/userReg}
1 解决办法:找到AFURLResponseSerialization 类 的
self.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
这个方法
改为
self.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript",@"text/plain", nil];
错误提示是数据解析的问题
只是添加了@"text/plain", 这个类型的数据 支持,这个问题就ok了
2 code =3840 上面问题改好了之后 紧接着会 遇到 code=3840的问题
问题提示如下
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.}
修改办法:
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.responseSerializer = [AFHTTPResponseSerializer serializer];//添加这句代码就好了
参考:http://www.codes51.com/article/detail_318121_1.html
http://www.itstrike.cn/question/e4f84935-c719-44ff-8418-4d8e7c8f2e38.html