I had install AFNetwork 3.1 by CocoaPods. When I call the post method i hit the error as below:
Request failed: unacceptable content-type: text/plain
Here is my code to call the post method:
AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc] initWithBaseURL:url];
manager.requestSerializer = [AFJSONRequestSerializer serializer]; manager.responseSerializer = [AFJSONResponseSerializer serializer]; manager.securityPolicy.allowInvalidCertificates = YES; manager.requestSerializer.timeoutInterval = 60; manager.securityPolicy.validatesDomainName = NO;
[manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];
[manager POST:urlStr parameters:parameters progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { NSLog(@"%@ success, responseObject: %@", url, responseObject); } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { NSLog(@"%@ error: %@", url, [error localizedDescription]); }];
How do I resolved this issue?