首页 > AFNetworking3.0 post发送body,服务器收不到body

AFNetworking3.0 post发送body,服务器收不到body

用的AFN3.0,向内网服务器post发送body,报错

Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: bad request (400)" UserInfo={com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x7bea8140> { URL: http://192.168.1.188:8080/mapi/index/index.json } { status code: 400, headers {
    Connection = close;
    "Content-Type" = "application/json;charset=UTF-8";
    Date = "Fri, 05 Feb 2016 03:56:30 GMT";
    Server = "Apache-Coyote/1.1";
    "Transfer-Encoding" = Identity;
} }, NSErrorFailingURLKey=http://192.168.1.188:8080/mapi/index/index.json, NSLocalizedDescription=Request failed: bad request (400), com.alamofire.serialization.response.error.data=<7b226865 6164223a 7b22636f 6465223a 302c2262 6d657373 61676522 3a224661 696c7572 6521222c 226d6573 73616765 223a2220 343034e6 89bee4b8 8de588b0 20e28094 20e69c8d e58aa1e5 99a8e689 bee4b88d e588b0e7 bb99e5ae 9ae79a84 e8b584e6 ba90efbc 9be69687 e6a1a3e4 b88de5ad 98e59ca8 222c2262 636f6465 223a307d 2c226461 7461223a 7b22656d 70747922 3a6e756c 6c7d7d>}

已经设置infoplist的NSAppTransportSecurity

//直接调的这个方法进行post
    [client POST:url
      parameters:bodys
        progress:nil
         success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
             XLog(@"%@",responseObject);

    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        XLog(@"%@",error);
    }];

有没有人遇到过这种问题?,求解决方法


我之前也遇到过这个问题, 应该是Content-Type设置有问题, 用afn默认的试试


400不是服务器错误嘛?

【热门文章】
【热门文章】