AFNetworking请求时的错误码笔记

405

Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: method not allowed (405)"

{ status code: 405, headers {   

Allow = GET;    "Cache-Control" = "no-cache"; 

  "Content-Length" = 63; 

  "Content-Type" = "application/json; charset=utf-8"; 

  Date = "Wed, 11 Apr 2018 06:14:34 GMT"; 

  Expires = "-1"; 

  Pragma = "no-cache";   

Server = "Microsoft-IIS/8.5"; 

  "X-AspNet-Version" = "4.0.30319"; 

"X-Powered-By" = "ASP.NET";} }

这种情况是我用post请求是出现的问题,原因是当前的请求只支持get请求。

解决方案:更换为Get请求

415

Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: unsupported media type (415)" UserInfo={NSLocalizedDescription=Request failed: unsupported media type (415), NSErrorFailingURLKey=https://tsgw.doudoujin.cn/api/v1/User/Login, com.alamofire.serialization.response.error.data=<>, com.alamofire.serialization.response.error.response= { URL: https://tsgw.doudoujin.cn/api/v1/User/Login } { Status Code: 415, Headers {     "Content-Length" =     (         0     );     Date =     (         "Mon, 11 Jun 2018 05:36:53 GMT"     );     Server =     (         Kestrel     );     "Strict-Transport-Security" =     (         "max-age=2592000"     );     "x-powered-by" =     (         "ASP.NET",         "ASP.NET"     ); } }}

这种情况需要设置manager

解决方案:

manager.requestSerializer = [[AFJSONRequestSerializer alloc]init];

你可能感兴趣的:(AFNetworking请求时的错误码笔记)