AFNetWorking发送post请求,后台接收格式不正确
Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: internal server error (500)" UserInfo={NSLocalizedDescription=Request failed: internal server error (500), NSErrorFailingURLKey=http://49.4.3.233:8081/signin, com.alamofire.serialization.response.error.data=<7b22636f 6465223a 22657272 6f722e69 6e746572 6e616c73 65727665 72222c22 6d657373 61676522 3a224261 64206372 6564656e 7469616c 73227d>, com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x60000003aca0> { URL: http://49.4.3.233:8081/signin } { Status Code: 500, Headers {
"Cache-Control" = (
"no-cache, no-store, max-age=0, must-revalidate"
);
Connection = (
close
);
"Content-Type" = (
"application/json;charset=UTF-8"
);
Date = (
"Wed, 15 Aug 2018 09:57:07 GMT"
);
Expires = (
0
);
Pragma = (
"no-cache"
);
"Transfer-Encoding" = (
Identity
);
"X-Content-Type-Options" = (
nosniff
);
"X-Frame-Options" = (
DENY
);
"X-XSS-Protection" = (
"1; mode=block"
);
} }}报这种错误。
各种验证后,发现是iOS正常发送的json格式,后台不认。最后更换成原生方式发送请求,设置
request.HTTPBody字符串,解决。