AFHTTPRequestOperationManager * manager = [AFHTTPRequestOperationManager manager]; AFJSONRequestSerializer * requestSerializer = [AFJSONRequestSerializer serializer]; [requestSerializer setValue:@“application / json”forHTTPHeaderField:@“Accept”]; manager.requestSerializer = requestSerializer; manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@“multipart / form-data”];
NSString *jsonString = [NSString stringWithFormat:@"{\"RequestCode\":\"%@\",\"RequestType\":\"%@\",\"DocumentTypeCode\":\"ABC123\"}", reqCode, type];
NSDictionary *parameter = @{@"request" : jsonString};
NSString *URLString = [NSString stringWithFormat:@"%@%@", baseUrl,uploadFile];
AFHTTPRequestOperation * op = [经理POST:URLString参数:参数constructBodyWithBlock:^(id formData){
[formData appendPartWithFileURL:[NSURL fileURLWithPath:imagePath]
name:@"Files"
error:nil];
} success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"Success %@", operation.responseString);
// [self parseData:responseObject withHandler:completionHandler];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error %@ \n Response %@", error, operation.responseString);
completionHandler(NO);
}];
[op start];
我尝试使用此代码,但出现了错误,例如 -
错误错误域= NSURLErrorDomain代码= -1001“请求超时。” UserInfo = 0x7c0a4980 {NSErrorFailingURLStringKey = http://prithiviraj.vmokshagroup.com:8033/api/upload,NSErrorFailingURLKey = http://prithiviraj.vmokshagroup.com:8033/api/upload,NSLocalizedDescription =请求超时。,NSUnderlyingError = 0x7c04d880“请求超时。”}
回应(null)
请有人帮我解决这个问题。 感谢致敬 Manasa