Maverick
Maverick

Reputation: 799

Python, Google Places API - "Invalid request. One of the input parameters contains a non-UTF-8 string"

I am trying to use the Google places API, but am getting the following error message on some of my requests:

Invalid request. One of the input parameters contains a non-UTF-8 string.

For example, the following request - https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=WRAFTON%HOUSE%SURGERY%WRAFTON%HOUSE%SURGERY%9%11%WELLFIELD%ROAD%HATFIELD%HERTFORDSHIRE%AL10%0BS&inputtype=textquery&fields=place_id,photos,formatted_address,name,rating,geometry,types&key=MY_API_KEY - is returning:

{
   "candidates" : [],
   "error_message" : "Invalid request. One of the input parameters contains a non-UTF-8 string.",
   "status" : "INVALID_REQUEST"
}

But if I remove the numbers like - https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=WRAFTON%HOUSE%SURGERY%WRAFTON%HOUSE%SURGERY%WELLFIELD%ROAD%HATFIELD%HERTFORDSHIRE%&inputtype=textquery&fields=place_id,photos,formatted_address,name,rating,geometry,types&key=MY_API_KEY - I get the expected data:

{
   "candidates" : [
      {
         "formatted_address" : "9-11 Wellfield Rd, Hatfield AL10 0BS, United Kingdom",
         "geometry" : {
            "location" : {
               "lat" : 51.7659979,
               "lng" : -0.2269138
            },
            "viewport" : {
               "northeast" : {
                  "lat" : 51.76722407989272,
                  "lng" : -0.2257391701072778
               },
               "southwest" : {
                  "lat" : 51.76452442010727,
                  "lng" : -0.2284388298927222
               }
            }
         },
         "name" : "Wrafton House Surgery NHS",
         "photos" : [
            {
               "height" : 2448,
               "html_attributions" : [
                  "\u003ca href=\"https://maps.google.com/maps/contrib/101621497138346721555/photos\"\u003eGicu Razoare\u003c/a\u003e"
               ],
               "photo_reference" : "CmRaAAAABVxpTtU1jnkajKeMys5GsNFha4PMisyTPaw4nyhpQMH0hwOu2kDDnGhKWXpsfiXqmBAGyO5ctA86dbtavh0xWZEspctQXo1EAcJswgxdnl0zSzG5b2xMbzSK6P6lRv2QEhCIPKzSjVUEQBSM3xutYsrwGhTGcax2XoglbtUgKsRFSIJF2oaQwA",
               "width" : 3264
            }
         ],
         "place_id" : "ChIJ85ML6oI8dkgRKziTLkoRGeA",
         "rating" : 1.9,
         "types" : [ "hospital", "point_of_interest", "establishment" ]
      }
   ],
   "status" : "OK"
}

Is this because of the numbers? Is there a way that I can get around this by not removing them?

Upvotes: 1

Views: 1716

Answers (1)

Related Questions