我正在为 iOS 9 使用 AFNetworking 3、Xcode 7.2。
AFURLSessionManager *ses = [[AFURLSessionManager alloc] initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
ses.responseSerializer = [AFJSONResponseSerializer serializer];
//Request
[[AFJSONRequestSerializer serializer] setValue:@"application/json" forHTTPHeaderField:@"Accept"];
NSMutableURLRequest *request = [[AFJSONRequestSerializer serializer] requestWithMethod:@"GET" URLString:endPoint parameters:parameters error:nil];
NSURLSessionDataTask *dataTask = [ses dataTaskWithRequest:request completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
if (error) {
NSLog(@"Error: %@", error);
} else {
NSLog(@"%@ %@", response, responseObject);
}
}];
[dataTask resume];
但我收到错误响应:
Domain=com.alamofire.error.serialization.response Code=-1016 “请求失败:不可接受的内容类型:文本/纯文本”
请求内容类型仍设置为“文本/纯文本”我不确定我缺少什么。