Vineesh TP
Vineesh TP

Reputation: 7943

Error Domain=NSURLErrorDomain Code=-1000 "bad URL" UserInfo=0x9eaa6b0

When start NSURLConnection some times I am getting these error.

But, not always get this error.

Error Domain=NSURLErrorDomain Code=-1000 "bad URL" UserInfo=0x9eaa6b0 {NSUnderlyingError=0xae8c730 "bad URL", NSLocalizedDescription=bad URL}

Upvotes: 0

Views: 1028

Answers (1)

Mohamed Jaleel Nazir
Mohamed Jaleel Nazir

Reputation: 5821

There is space in the url is reason for that mistake.

NSString *urlString =[NSString stringWithFormat:@"&street=%@&street2=&city=%@&state=%@&
zipcode=%@&candidates=10", address.address2,address.city, address.state, address.zip5];
NSLog(@"BAD URL - %@",urlString ); // there is space in url

NSString *encodedUrl = [urlString stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
NSLog(@" CORRECT URL - %@", encodedUrl); // url encode that space by %20


NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL RLWithString:encodedUrl]];

Upvotes: 2

Related Questions