简体   繁体   English

Google Places API,添加位置始终返回INVALID_REQUEST

[英]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. 以下是在向我的项目中添加地点时遇到的问题:1. Google所理解的类型未列出地点的“ 类型 ”。 Make sure that type added is given in supported types . 确保添加的类型受支持的类型中给出。 2. The required types are all included in the request placed. 2. 要求的类型都包含在所下的请求中。 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 . (请检查“地方添加”中的请求正文部分,以确保您的请求有效性。)3.发送的请求格式正确,并使用正确的内容类型编码。

Hope, this answer was useful. 希望这个答案很有用。

Regards, Karan 问候,卡兰

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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