afnetworking-2

AFnetworking multipart request body is nil

半城伤御伤魂 提交于 2019-12-01 20:38:51
问题 I am trying to upload picture to server, via af 2.0 multipart request, but it seems body is always null. Here is a snapshot from code: [self POST:path parameters:params constructingBodyWithBlock:^(id<AFMultipartFormData> formData) { [formData appendPartWithFormData:file name:@"file"]; } success:^(NSURLSessionDataTask *task, id responseObject) { andAPIResponseType:apiResponseType]; } failure:^(NSURLSessionDataTask *task, NSError *error) { }]; where file is photo that i took from device camera

How To POST JSON Parameters Using AFNetworking?

你离开我真会死。 提交于 2019-12-01 17:52:46
how can I POST JSON parameters with AFNetworking ? Below is the example JSON format. Thank you in advance. { "application": { "identifier": "appDev" }, "sso": { "version": 2.0, "session_expiry": 43200 }, "user": { "password": "xxxx~!@", "username": "xxx0min" }, "coordinate": { "latitude": 10.9948629, "longitude": -169.5213749 } } I successfully created a JSON : NSDictionary *parameters = @{@"application": @{@"identifier": @"appDev"}, @"sso": @{@"version": @"2.0", @"session_expiry":@43200}, @"user": @{@"password":@"xxxx~!@", @"username":@"xxx0min"}, @"coordinate": @{@"latitude":@10.9948629, @

AFNetworking 2.0 POST issue, Cocoa error 3840(JSON text did not start with array…)

泪湿孤枕 提交于 2019-12-01 17:14:11
I am attempting to call api.php on my local server(using MAMP). The server side api.php is being called but the content of _POST inside the php code contains the following error: Error Domain = NSCocoaErrorDomain Code = 3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (JSON text did not start with array or object and option to allow fragments not set.) UserInfo = 0x15d7bdd0 {NSDebugDescription = JSON text did not start with array or object and option to allow fragments not set.} My app that is trying to send the JSON POST request to the api.php is an iOS app using AFNetworking 2

Load offline cached JSON using AFNetworking

三世轮回 提交于 2019-12-01 14:21:41
I've been trying to implement caching using AFNetworking so my cached JSON will be loaded offline. i tried my best in different ways i couldn't make the cache work at all. i don't know what am i missing here.. Here is the code in my AppDelegate : func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // Override point for customization after application launch. var cache :NSURLCache = NSURLCache(memoryCapacity: 4*1024*1024, diskCapacity: 32*1024*1024, diskPath: "app_cache") NSURLCache.setSharedURLCache(cache) return true }

Load offline cached JSON using AFNetworking

折月煮酒 提交于 2019-12-01 12:53:19
问题 I've been trying to implement caching using AFNetworking so my cached JSON will be loaded offline. i tried my best in different ways i couldn't make the cache work at all. i don't know what am i missing here.. Here is the code in my AppDelegate : func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // Override point for customization after application launch. var cache :NSURLCache = NSURLCache(memoryCapacity: 4*1024*1024,

Download file using AFNetworking on iOS 6

你离开我真会死。 提交于 2019-12-01 11:33:52
I've recently updated to AFNetworking 2.0. The documentation said it is compatible with iOS6.0+. I am building a iOS 6.0 app, when I am trying to implement a download method (both images and videos). The example use AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration]; However, I got an "Use of undeclared identifier 'AFURLSessionManager'" error. And I found out that AFURLSessionManager use a class that is only available from iOS7. I'm just wondering, who could I download in iOS6 using AFNetworking? Also, is there anyway to see download

Response failure when using AFHTTPRequestOperationManager

ぃ、小莉子 提交于 2019-12-01 07:51:30
问题 When i tried to call API(AFHTTPRequestOperationManager) for authentication method with exact username and password getting exact response and method was success. Then i tried with invalid username and password I'm getting response is failure. i tried ASIHTTPRequest API for same method its working fine. So please check below request and response and advice me how to resolve this issues. But in AFHTTPRequestOperationManager invalid user response is failure. ASIHTTPRequest CALL sample:

Cancel Post request in Afnetworking 2.0

余生颓废 提交于 2019-12-01 05:37:42
Hi I am making post request using AFnetworking 2.0. My request looks like this. AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; manager.responseSerializer = [AFXMLParserResponseSerializer serializer]; [manager.requestSerializer setValue:@"some value" forHTTPHeaderField:@"x"]; [manager POST:url parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) { //doing something } failure:^(AFHTTPRequestOperation *operation, NSError *error) { // error handling. }]; How can i cancel this request??? POST method return the AFHTTPRequestOperation

How can I POST an NSArray of NSDictionaries inside an NSDictionary without problems?

∥☆過路亽.° 提交于 2019-12-01 05:04:39
问题 I do know how to do this, it's fairly simple. The problem is that it doesn't work. Here's the function I use to POST the data: - (void)updateWebsitesUsingParameters:(NSDictionary *)parameters; { AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; [manager POST:@"http://notreal/updateWebsites.php" parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) { NSLog(@"JSON: %@", responseObject); //... } failure:^(AFHTTPRequestOperation

AFNetworking 2 Response Error (Content type: text/html and not JSON)

柔情痞子 提交于 2019-12-01 03:44:01
问题 After trying nearly every response on the subject, I've come up without a working answer to my problem. The problem: So I've implemented the uploading portion of my app using AFNetworking 2.0.3 after porting from AFNetworking 1.3 : -(void)commandWithParams:(NSMutableDictionary*)params onCompletion:(JSONResponseBlock)completionBlock { NSData* uploadFile = nil; if ([params objectForKey:@"file"]) { uploadFile = (NSData*)[params objectForKey:@"file"]; [params removeObjectForKey:@"file"]; }