Search code examples
iphonexcodeasihttprequestasiformdatarequest

How to print request string when ASIFormDataRequest failed?


I am using ASIFormDataRequest asynchronously to get data from server. When request failed for any reason then I want to save URL and requested string in database for further reference.

I am getting the URL from [request url] but how to get requested string from request. Below code I am using.

 ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];

 [request setPostValue:requestString forKey:@"data"];

 [request setDelegate:self];

 [request startAsynchronous];

 //DELEGATE METHOD
 - (void)requestFailed:(ASIHTTPRequest *)request
 {
     //PRINT REQUEST STRING WHEN FAILED
 }

Thanks in advance.


Solution

  • Try to use [request setFailedBlock:^{...//print url...}];