-2

I have to get many google places ids and data given (City, Country, Province), the data that I have are mainly are names, for example São Paulo, Brazil the thing is that since the google locations API it receives the parameters on URI it fails because URI must be ascii only ex:GET https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=Sao Paulo%20Brazil%20S\u00E3o Paulo&inputtype=textquery&key=XXXXX"

I want to know if google provide a different API with similar goal, mainly getting place id from string names and accepting non ascii names on payload, or if I should go for a solution trying to change the encoding.

Hernan Acosta
  • 377
  • 5
  • 19

1 Answers1

1

Find Place API accepts ASCII characters, which are translated into a different encoding before transmission.

Your input São Paulo, Brazil translates to S%C3%A3o%20Paulo%2C%20Brazil. This translation is different from your Find Place API input Sao Paulo%20Brazil%20S\u00E3o Paulo.

Here's the Find Place API web request with the correct translation:

https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=S%C3%A3o%20Paulo%2C%20Brazil&inputtype=textquery&key=YOUR_API_KEY

This request returns a Place ID ChIJ0WGkg4FEzpQRrlsz_whLqZs in the response, which corresponds to the address São Paulo, State of São Paulo, Brazil.

Here's a link where you can encode/decode your special characters: https://www.url-encode-decode.com/

Beth
  • 307
  • 1
  • 4