AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];;
manager.requestSerializer = [AFJSONRequestSerializer serializer];
manager.responseSerializer = [AFJSONResponseSerializer serializer];
manager.responseSerializer.acceptableContentTypes = [manager.responseSerializer.acceptableContentTypes setByAddingObject:@"application/json"];
[manager POST:url
parameters:parameter
success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"Response JSON: %@", data);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
上面的代码在iOS7中工作正常但我在ios8中得到了错误代码。
状态代码:401,标题
"Cache-Control" = "no-cache";
Connection = "keep-alive";
"Content-Type" = "application/json; charset=utf-8";
Date = "Mon, 10 Nov 2014 09:22:04 GMT";
Server = "nginx/1.4.6 (Ubuntu)";
"Set-Cookie" = "request_method=POST; path=/";
"Transfer-Encoding" = Identity;
"X-Content-Type-Options" = nosniff;
"X-Frame-Options" = SAMEORIGIN;
"X-Request-Id" = "971366a5-f11d-4f3c-8a0f-0618905d43f4";
"X-Runtime" = "0.003365";
"X-XSS-Protection" = "1; mode=block";
提前感谢您的帮助。