ios - AFNetworking3.0 post发送body,服务器收不到body
黄舟
黄舟 2017-04-17 17:29:52
[iOS讨论组]

用的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);
    }];

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

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

全部回复(2)
伊谢尔伦

400不是服务器错误嘛?

高洛峰

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

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号