I have a problem that really makes me scratch my head. There seems to be no logical reason why this is happening. If I hardcode the string in NSURL, it works. But if I pass in NSString, this will not work. I confirmed that NSString is identical to the NSLog string chain, both of them.
Code that works. The server returns a 200 response code.
//NSString * urlStr = [NSString stringWithFormat:@"http://www.server.com/%@",monograph.uri]; NSURL *url = [NSURL URLWithString:@"http://www.server.com/api/monograph/com/3894.json"]; ASIHTTPRequest *request; request = [ASIHTTPRequest requestWithURL:url]; [request setUsername:appDelegate.key]; [request setPassword:appDelegate.secret]; [request setDelegate:self]; [request startAsynchronous];
Failed to execute code. The server returns 204 response codes for this:
NSString * urlStr = [NSString stringWithFormat:@"http://www.server.com/%@",monograph.uri]; NSURL *url = [NSURL URLWithString:urlStr]; ASIHTTPRequest *request; request = [ASIHTTPRequest requestWithURL:url]; [request setUsername:appDelegate.key]; [request setPassword:appDelegate.secret]; [request setDelegate:self]; [request startAsynchronous];
When I NSLog urlStr contains:
http://www.server.com/api/monograph/com/3894.json
What am I missing? There must be something to explain this. -
Regards, Code
EDIT
checked the length of both lines, and they have the same lengths, so there seems to be no white spaces or anything hidden there.
user440096
source share