quantumpotato
quantumpotato

Reputation: 9767

ASIHTTP Request failed in log, but requestFailed not getting called

I have

-(void)requestFailed:(ASIHTTPRequest *)request
{
    NSError *error = [request error];
    NSLog(@"Request Failed Error: %@", error);
}

When I make my request I do

    //add data to the array
    NSString *json = [array JSONRepresentation];
[request appendPostData:[json dataUsingEncoding:NSUTF8StringEncoding]];

[request startAsynchronous];

I'm getting this in my log:

 0-08-11 16:52:11.652 MyProject[11720:207] Starting asynchronous request <ASIHTTPRequest: 0x5a7df10>

2010-08-11 16:52:11.861 MyProject[11720:207] Request finished downloading data 2010-08-11 16:52:11.861 MyProject[11720:207] Request failed: (gdb)

But my log statement in

 -(void)requestFailed

is not getting called. Any ideas?

Cheers

Upvotes: 0

Views: 814

Answers (2)

JosephH
JosephH

Reputation: 37495

-requestFailed: is only returned when a request can't be completed - eg. failure to contact the server, or the server didn't conform to the http protocol.

If request can be completed, requestFinished will be called, and you can then check the http status code there, which may indicate a failure. responseStatusText may give more information as to what the failure was.

Upvotes: 1

Alex Reynolds
Alex Reynolds

Reputation: 96937

Did you set the request's delegate and didFailSelector properties? Usually:

[request setDelegate:self];
[request setDidFailSelector:@selector(requestFailed:)];

suffices if the -requestFailed: method is in the same class implementation file.

Also set the didFinishSelector property to call a local selector when then request finishes correctly.

Upvotes: 1

Related Questions