AFNetwork 3.0网络请求常见问题

问题1: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., 
NSUnderlyingError=0x17105df10 {Error Domain=com.alamofire.error.serialization.response Code=-1011 "
Request failed: internal server error (500)" UserInfo={com.alamofire.serialization.response.error.
response=<NSHTTPURLResponse: 0x170622420> { URL: http://syspd.w-oasis.com/urcarAppRmiServlet } { status code: 500, headers {
    Server = Apache-Coyote/1.1,
    Content-Type = text/html;charset=utf-8,
    Set-Cookie = JSESSIONID=4D96EDA3BF1417BA495D6920EBE44CC7; Path=/; HttpOnly,
    Content-Language = en,
    Vary = Accept-Encoding,
    Date = Fri, 14 Oct 2016 07:27:36 GMT,
    Content-Encoding = gzip,
    Content-Length = 848,
    Connection = close
} }, 

解决办法:

//设置请求格式
manager.requestSerializer = [AFJSONRequestSerializer serializer];

//设置返回格式
manager.responseSerializer = [AFHTTPResponseSerializer serializer];

问题2:Code=-1016 错误

Error Domain=com.alamofire.error.serialization.response Code=-1016 
"Request failed: unacceptable content-type: text/plain" 
UserInfo={com.alamofire.serialization.response.error.
response=<NSHTTPURLResponse: 0x174227f20> { URL: http://syspd.w-oasis.com/urcarAppRmiServlet } 
{ status code: 200, headers {
    Keep-Alive = timeout=5, max=100,
    Content-Length = 205,
    Connection = Keep-Alive,
    Server = Apache-Coyote/1.1,
    Date = Fri, 14 Oct 2016 07:31:16 GMT
} }

问题3:code: 503

 { status code: 503, headers {
    Cache-Control = must-revalidate,no-cache,no-store;
    Content-Type = text/html;charset=ISO-8859-1;
    Content-Length = 925;
    Server = Charles;
    Proxy-Connection = Close;
}

解决办法:可能是断网了,请重新连接!😄

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值