Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

IDMah

macrumors 6502
Original poster
May 13, 2011
317
11
Hi all.

I'm moving my app from earlier version of AFNetworking to 2.0.

The POST seem to work (see it added to mysql) but it's returning an error.
very confusing.

Code:
        NSURL *url = [NSURL URLWithString:PUTURL]; // PUTURL set to http://localion_of_PHP/
                AFHTTPRequestOperationManager *httpClient = [[AFHTTPRequestOperationManager manager] initWithBaseURL:url]; 
                 
                // PUTPHP = PHPcode.php //             
      // httpClient.requestSerializer = [AFJSONRequestSerializer serializer];                 
       [httpClient POST:PUTPHP parameters:paramass success:^(AFHTTPRequestOperation *operation, id responseObject) {
                    NSString *responseStr = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
                    NSLog(@"Request Successful, response '%@'", responseStr);
                    sharedHSData.queuedItems=NO;
                    
                    uploadError = NO;
                    [[NSNotificationCenter defaultCenter] postNotificationName:@"JSONCOMPLETED"
                                                                        object:nil];
                    
                } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
                    // if we fail add the score to a send Que and load the old // 
                    NSLog(@"ID= %i [Alert Send HTTPClient Error]: %@",highScoreIdent, error.localizedDescription);
 
                    [self enableOKButton];
                    
                }]

Here is the Error:
Code:
 ID= 0 [Alert Send HTTPClient Error]: The operation couldn’t be completed. (Cocoa error 3840.)

ideas??
thanks
Ian
 
Last edited:
Sussed!

I needed to format the response.. (serialize)

added.
Code:
httpClient.responseSerializer = [AFHTTPResponseSerializer serializer];
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.