I'm trying to upload a pdf file with AFNetworking 3.0 to a server,
My pdf file was send in NSData in the formData but it's returning me this error :
NSError * domain: @"com.alamofire.error.serialization.response" - code: 18446744073709550605
There my code :
-(void)uploadPDFFile{
NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:@"POST" URLString:@"URLREQUEST" parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
[formData appendPartWithFileData:self->originalDataPDF name:@"fileName" fileName:self->fileNamePDF mimeType:@"application/pdf"];
}
error:nil];
AFURLSessionManager *manager = [[AFURLSessionManager alloc]
initWithSessionConfiguration:[NSURLSessionConfiguration
defaultSessionConfiguration]];
manager.responseSerializer = [AFHTTPResponseSerializer serializer];
NSURLSessionUploadTask *uploadTask;
uploadTask = [manager uploadTaskWithStreamedRequest:request
progress:^(NSProgress * _Nonnull uploadProgress) {
// This is not called back on the main queue.
// You are responsible for dispatching to the main queue for UI updates
}
completionHandler:^(NSURLResponse * _Nonnull response, id _Nullable responseObject, NSError * _Nullable error) {
if (error) {
NSLog(@"%@",[[NSString alloc]initWithData:responseObject encoding:NSUTF8StringEncoding]);
} else {
NSLog(@"WORKING ");
}
}];
[uploadTask resume];
}
When print the responseObject the error Log return me this :
406 Not AcceptableNot Acceptable
An appropriate representation of the requested resource could not be found on this server.
Additionally, a 406 Not Acceptable error was encountered while trying to use an ErrorDocument to handle the request.
Thanks for your help