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)"; } }
求助各位大神能够解答一下,是我漏掉了哪些设置没弄上去,还是怎样的?谢谢。