首页新闻找找看学习计划

使用SWIFT的第三方库Alamofire不能成功请求

0
悬赏园豆:10 [待解决问题]

SWIFT-Alamofire请求代码如下:

var request: Request?
request = Alamofire.request(.POST, url, parameters: pa2).validate(contentType: ["application/json"])
request?.responseString { (request, response, body, error) in
    print(request)
}

OC-AFN成功请求对比

AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
AFJSONRequestSerializer *afjsonRequestSerializer = [[AFJSONRequestSerializer alloc] init];
[afjsonRequestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
manager.requestSerializer = afjsonRequestSerializer;
NSString *RequestURL = [NSString stringWithFormat:@"%@%@",CPSURL,ServerName];
[manager POST:RequestURL parameters:Parameters success:success failure:failure];

这两边的参数和URL都是一样的,但是在OC-AFN里可以成功请求到,但在SWIFT的Alamofire请求却不成功,每次返回都为500:

 { status code: 500, headers {
    "Cache-Control" = "must-revalidate,no-cache,no-store";
    "Content-Length" = 5526;
    "Content-Type" = "text/html;charset=ISO-8859-1";
    Server = "Jetty(8.y.z-SNAPSHOT)";
} }

求助各位大神能够解答一下,是我漏掉了哪些设置没弄上去,还是怎样的?谢谢。

GarveyCalvin的主页 GarveyCalvin | 初学一级 | 园豆:192
提问于:2014-11-26 09:47
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册