method execute failure block ios

280 Views Asked by At

I have been using AFHTTPClient class' postPath:parameters:success:failure: method. but it always call failure block only. I have been using AFNetworking 0.10 library. Can anyone tell me the possible reasons for this.

following is the code:

NSURL *nsUrl = [NSURL URLWithString:kURLAuthLogin];
AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:nsUrl];
[httpClient postPath:nil parameters:loginParams success:^(AFHTTPRequestOperation *operation, id responseObject) {

    NSLog(@"\n\n\n\n\n\n login success \n\n\n\n\n\n");

} failure:^(AFHTTPRequestOperation *operation, NSError *error) {

    NSLog(@"\n\n\n\n\n\n login failed \n\n\n\n\n\n");

}];

There is no any problem with nsUrl or any other variable for sure.

2

There are 2 best solutions below

0
gnasher729 On

What happened is that your login failed. It would be common sense to

NSLog (@"%@", error);

to get the information you are looking for.

0
jayraj m.g. On

did you made your NSString to support NSURL with adding percentage.

example:-

 NSString *loginCredential=[@"Your Url with login and password" stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];