Google places add place INVALID_REQUEST error

余生颓废 提交于 2020-01-03 04:54:26

问题


I create post

POST https://maps.googleapis.com/maps/api/place/add/json?sensor=false&apiKey HTTP/1.1
Content-Type: application/json
Host: maps.googleapis.com
Content-Length: 100
Expect: 100-continue
Connection: Keep-Alive

{"location":{"lat":"50.873884","lng":"20.650160899999946"},"accuracy":50,"name":"new place name"}

I am getting

HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Vary: Accept-Language
Date: Wed, 14 Sep 2011 14:02:25 GMT
Server: mafe
Cache-Control: private
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN
Transfer-Encoding: chunked

24
{
   "status" : "INVALID_REQUEST"
}

0

Where is the error?

string json = JsonHelper.ObjectToJson(jsonRequest);
byte[] postdata = System.Text.Encoding.ASCII.GetBytes(json);

WebClient client = new WebClient();
client.Headers.Add("Content-Type", "application/json");
string url = string.Format("https://maps.googleapis.com/maps/api/place/add/json?sensor={0}&key={1}", "false", ConfigurationManager.AppSettings["GooglePlacesKey"]);

byte[] bret = client.UploadData(url,"POST", postdata);

string sret = System.Text.Encoding.ASCII.GetString(bret);

JavaScriptSerializer ser = new JavaScriptSerializer();
GooglePlecesResponse GoogleResponse = ser.Deserialize<GooglePlecesResponse>(sret);

回答1:


location (lat,lng) was string not numerical ...



来源:https://stackoverflow.com/questions/7417764/google-places-add-place-invalid-request-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!