gpt4 book ai didi

java - Google Places API,添加地点始终返回 INVALID_REQUEST

转载 作者:行者123 更新时间:2023-12-01 05:41:07 26 4
gpt4 key购买 nike

代码如下:

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);

你能看出有什么问题吗?

最佳答案

有许多因素会影响响应。以下是我在向项目添加地点时遇到的问题:1. 地点的“类型”未在 Google 理解的类型中列出。确保添加的类型在 supported types 中给出。2. 必填类型均包含在所发出的请求中。还要确保它的格式符合预期。 (请检查“地点添加”中的 request body 部分,以确保您的请求有效。)3. 发送的请求格式正确,并使用正确的内容类型进行编码。

希望这个答案有用。

问候,卡兰

关于java - Google Places API,添加地点始终返回 INVALID_REQUEST,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7147605/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com