1

This question is already answered at many places but no solution is working for me! I m using code for AFNetworking as following

AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; manager.responseSerializer=[AFJSONResponseSerializer serializer]; NSDictionary *parameters=@{@"Key1":@"Value1",@"Key2":@"Value2"}; // NSDictionary *parameters = @{@"foo": @"bar"}; [manager POST:@"https://www.MyURL.com/index.php" parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) { NSLog(@"JSON: %@", responseObject); } failure:^(AFHTTPRequestOperation *operation, NSError *error) { NSLog(@"Error: %@", error); }]; 

Error :

Error: Error Domain=NSURLErrorDomain Code=-1012 "The operation couldn’t be completed. (NSURLErrorDomain error -1012.)" UserInfo=0x7a2a03b0 {NSErrorFailingURLKey=https://www.MyURL.com/index.php, NSErrorFailingURLStringKey=https://www.MyURL.com/index.php} 

I got no luck for above request.

I do not know what is wrong with my code in POST Request, GET Request is working fine in the AFNetworking.

3
  • ASIHTTPRequest has been no longer updated since 2011. Check ASIHTTPRequest Commented Oct 14, 2014 at 12:56
  • @Prince: if you go to the github.com/pokeb/asi-http-request you will know that it has been updated 7 month before. I m converting my code to AFNetworking but POST request is not working that is why I asked help. Commented Oct 14, 2014 at 13:02
  • add Error in question so other can know whats problem? Commented Oct 14, 2014 at 13:10

1 Answer 1

1

Try this one :

 NSDictionary *dictParameters = parameter here //create url NSString *strURL = [NSString stringWithFormat:@"url here"]; NSLog(@"loginurl : %@",strURL); AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; manager.responseSerializer = [AFHTTPResponseSerializer serializer]; AFHTTPRequestOperation *apiRequest = [manager POST:strURL parameters:dictParameters success:^(AFHTTPRequestOperation *operation, id responseObject) { NSData *jsonData = (NSData *)responseObject; NSError * parsedError = nil; id *value = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingAllowFragments error:&parsedError]; if (parsedError == nil) { //Successfull } else { NSLog(@"wrong while parsing json data"); } } failure:^(AFHTTPRequestOperation *operation, NSError *error) { NSLog(@"Error : %@",[error description]); }]; //start request right now [apiRequest start]; 

EDIT : Just Formatted

Sign up to request clarification or add additional context in comments.

2 Comments

Error: Error Domain=NSURLErrorDomain Code=-1012 "The operation couldn’t be completed. (NSURLErrorDomain error -1012.)" UserInfo=0x7aef7b00 {NSErrorFailingURLKey=fantasyguru.com/ws/myguru/index.php, NSErrorFailingURLStringKey=fantasyguru.com/ws/myguru/index.php}

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.