简体   繁体   中英

Google Places API, Adding a place always returns INVALID_REQUEST

Here's the code:

googleMapsAPICall = "https://maps.googleapis.com/maps/api/place/add/json?sensor=true&key=MY_KEY_HERE";
HttpPost post = new HttpPost(googleMapsAPICall);
String postBody = "{\"location\":{\"lat\":-33.8669710,\"lng\":151.1958750},\"accuracy\":50.0,\"name\":\"testingjson\",\"types\":[\"other\"],\"language\":\"en\"}";
StringEntity se = new StringEntity(postBody,HTTP.UTF_8);
post.setEntity(se);
httpClient = new DefaultHttpClient();
response = httpClient.execute(post);

Can you see something wrong?

The are a number of factors which can affect the response. Following are issues that I came across while adding places to my project: 1. ' type ' of place was not listed in types understood by google. Make sure that type added is given in supported types . 2. The required types are all included in the request placed. Also make sure that it is in the right format as expected. (Please check the request body section in 'place add' to ensure your request validity.) 3. The request sent is in the correct format and encoded with right content type .

Hope, this answer was useful.

Regards, Karan

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM