Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone and ASIHTTPRequest - Unable to start HTTP connection

I am using the ASIHTTPRequest class in order to communicate with a web service and get a response. This is how I send a request to the server

NSString *str = [NSString stringWithFormat:@"%@verifyLogin.json", serverUrl];
NSURL *url = [NSURL URLWithString:[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
ASIHTTPRequest *request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease];
[request addRequestHeader:@"Content-Type" value:@"text/x-gwt-rpc; charset=utf-8"];
NSDictionary* data = [NSDictionary dictionaryWithObjectsAndKeys:emailId, @"username", pwd, @"password", nil];
[request appendPostData: [[data JSONFragment] dataUsingEncoding: NSUTF8StringEncoding]];
[request setRequestMethod:@"POST"];
[request setDelegate:self];
[request setDidFinishSelector: @selector(gotLoginResponse:)];
[request setDidFailSelector: @selector(loginRequestFailed:)];

[networkQueue addOperation: request];
[networkQueue go];

The control immediately goes to the error routine and the error description and domain are

Unable to start HTTP connection and ASIHTTPRequestErrorDomain

I can get the same request to work via a desktop tool for checking HTTP requests so I know the settings are all correct.

Can someone please tell me what I am missing here while sending the request?

Thanks.

like image 675
lostInTransit Avatar asked Oct 20 '09 13:10

lostInTransit


1 Answers

As I commented earlier;

in your first line it says "%verifyLogin.json". Shouldn't that be; "%@verifyLogin.json" ????

like image 60
Jake Avatar answered Oct 07 '22 01:10

Jake