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_HER开发者_如何学运维E";
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
精彩评论