Reputation: 16256
When i try to look for a location like this: Florida,USA
it goes OK, but when i try it like this: Florida USA
, i got that error:
Unable to create Request (bad url?)
The problem belongs with the spaces on the location taped, is there any way to resolve that?
NSString *urlString = [NSString stringWithFormat:@"https://maps.googleapis.com/maps/api/geocode/json?address=%@&sensor=true",theLocationString];
//Create a URL object.
NSURL *url = [NSURL URLWithString:urlString];
ASIFormDataRequest *request=[ASIFormDataRequest requestWithURL:url];
Upvotes: 1
Views: 1393
Reputation: 17617
I think the problem is that you need to urlencode your string. A space character isn't a valid url string:
NSString *urlString = [NSString stringWithFormat:@"https://maps.googleapis.com/maps/api/geocode/json?address=%@&sensor=true",theLocationString];
//Create a URL object.
NSURL *url = [NSURL URLWithString:[urlString stringByAddingPercentEscapesUsingEncoding:
NSASCIIStringEncoding]];
ASIFormDataRequest *request=[ASIFormDataRequest requestWithURL:url];
If NSASCIIStringEncoding
doesn't work you could try: NSUTF8StringEncoding
..fredrik
Upvotes: 8