Eme Emertana
Eme Emertana

Reputation: 571

Can not make a request to google map

Hi I am making a restful request to google map, but I run into following error;

java.io.IOException: Server returned HTTP response code: 400 for URL: 
       http://maps.googleapis.com/maps/api/distancematrix/xml?origins=Washington, DC  
        USA&destinations=Los+Angeles+CA+USA&mode=driving&sensor=false
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1436)
at java.net.URLConnection.getContent(URLConnection.java:688)

I believe its making a correct connection as I can get the correct response by copying the above URL into my browser, I am wondering why I am getting 400 error code in my console and I dont get the correct response when java is sending the request.

Upvotes: 0

Views: 701

Answers (1)

Eme Emertana
Eme Emertana

Reputation: 571

The solution is that I should replace all the spaces with the + in both origin and destination.

Upvotes: 2

Related Questions