本文介绍了Google地方添加了INVALID_REQUEST错误的地方的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了帖子
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"}
我得到
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
错误在哪里?
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);
推荐答案
location(lat,lng) ..
location (lat,lng) was string not numerical ...
这篇关于Google地方添加了INVALID_REQUEST错误的地方的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!