首先說下解決辦法
1: code=1016
錯(cuò)誤提示:
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]; ?
這個(gè)方法 ?
改為
self.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript",@"text/plain", nil];
錯(cuò)誤提示是數(shù)據(jù)解析的問題
只是添加了@"text/plain", 這個(gè)類型的數(shù)據(jù) 支持伶授,這個(gè)問題就ok了
2 code =3840 上面問題改好了之后 緊接著會(huì) 遇到 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