pazukdev
pazukdev

Reputation: 133

Google Maps Static API request isn't working over https and http2 (h2)

I have a webpage served over https which should display an image created via the Google Maps Static API. I try to create the map image by making a request to the API via http like this:

<img src="http://maps.googleapis.com/maps/api/staticmap?client=CLIENT_ID&signature=MY_SIGNATURE"/>

But in Chrome > "Inspect" > "Network" tab I see request to "https://maps.googleapis.com/maps/api/staticmap?client=CLIENT_ID&signature=MY_SIGNATURE" (via http2, I guess)

Also when I try to execute "https://maps.googleapis.com/maps/api/staticmap?client=CLIENT_ID&signature=MY_SIGNATURE" request via browser address bar I get 400 error with error message "Your client has issued a malformed or illegal request".

When I'm trying to send http and https request via Postman I'm getting next results:

Can anybody tell me what's going on here?

Upvotes: 0

Views: 43

Answers (1)

pazukdev
pazukdev

Reputation: 133

Cause The URL of the image contains params that are passed unencoded in UTF-8. And because of one of these unencoded params, namely the "path" parameter, Google identified the URL as malformed or invalid and returned a 400 error.

Fix Encode "path" param in UTF-8.

Upvotes: 0

Related Questions