0

我使用 OAuth2 授权示例http://code.google.com/p/google-api-dotnet-client/wiki/OAuth2,但我使用 Fusion Tables 服务而不是任务服务。

问题是当我尝试在表中插入新行时出现错误 414 - 请求 URI 太大。

const string Geometry = "<Polygon>" + "<outerBoundaryIs>" + "<LinearRing>" + "<coordinates>" +
"-86.8331071413617,33.9491997229225 -86.8207076186559,33.9412000308542 -86.8207076186559,33.9575993995941 -86.7907087734001,33.9531995689566 -86.7919087272103,33.9631991840419 -86.7627098511612,33.9755987067476 -86.7611099127476,33.9955979369182 -86.7415106671804,33.9991977983489 -86.7203114831996,34.0323965204321 -86.707111991287,34.0299966128117 -86.7043120990631,34.0579955350505 -86.6843128688925,34.0543956736198 -86.7047120836665,34.0803946728416 -86.6923125609607,34.0923942109439 -86.6867127765129,34.0795947036348 -86.6687134693594,34.0835945496689 -86.6527140852229,34.107993610477 -86.622715239967,34.1227930408032 -86.6131156094851,34.1135933949248 -86.5995161329691,34.1199931485794 -86.5903164870907,34.1463921324046 -86.5455182115085,34.1855906235389 -86.5555178265938,34.1887905003662 -86.5543178727836,34.2051898691061 -86.5399184270608,34.2255890838801 -86.5235190583209,34.2263890530869 -86.5195192122867,34.2519880677053 -86.4531217681204,34.2591877905667 -86.3035275264443,34.0991939492019 -86.3323264178899,34.0463959815516 -86.3335263717002,33.9819984604022 -86.3703249552141,33.9396000924406 -86.3255266796319,33.940000077044 -86.3487257866298,33.9100012317881 -86.3423260329752,33.8868021247902 -86.4083234925382,33.8340041571398 -86.4303226457259,33.819604711417 -86.4451220760521,33.8260044650716 -86.5219191199072,33.8020053888668 -86.5775169797815,33.8020053888668 -86.5743171029542,33.7652068053529 -86.647914269982,33.7660067745598 -86.7591099897305,33.8408038953978 -86.883905185995,33.8432038030183 -86.9535025069887,33.8152048807794 -86.963502122074,33.8584032179479 -86.9623021682638,33.8676028638264 -86.947902722541,33.8616030947752 -86.9519025685751,33.8716027098605 -86.9203037849055,33.8728026636708 -86.9275035077669,33.8984016782891 -86.9167039234748,33.9156010162358 -86.8867050782189,33.9168009700461 -86.8859051090121,33.9340003079928 -86.8595061251869,33.9292004927519 -86.8331071413617,33.9491997229225" +
"</coordinates>" + "</LinearRing>" + "</outerBoundaryIs>" + "</Polygon>";

var sqlValue = string.Format(
"INSERT INTO {0} (Hash, Geometry, Timestamp) VALUES ('3eb906069dd01a74352a2b1f9e5cec3f', '{1}', '{2}')", 
TableId, Geometry, DateTime.Now);

var sqlresponse = service.Query.Sql(sqlValue).Fetch();

似乎使用了 GET 请求而不是 POST。有人可以告诉我我的代码有什么问题,或者是否可以插入大量数据?

更新

官方 FusionTables API 参考告诉不应提供“sql” api 方法的请求正文。如果我们将尝试使用https://developers.google.com/apis-explorer/#p/fusiontables/v1/fusiontables.query.sql用下一个 sql 测试我们的 INSERT 请求:

INSERT INTO 1Fyxt7bxFiCaT5jnUHdzv8xoCA6C8ERysS-aXELg (Hash, Geometry, Timestamp) VALUES ('3eb906069dd01a74352a2b1f9e5cec3f', '<Polygon><outerBoundaryIs><LinearRing><coordinates>-86.8331071413617,33.9491997229225 -86.8207076186559,33.9412000308542 -86.8207076186559,33.9575993995941 -86.7907087734001,33.9531995689566 -86.7919087272103,33.9631991840419 -86.7627098511612,33.9755987067476 -86.7611099127476,33.9955979369182 -86.7415106671804,33.9991977983489 -86.7203114831996,34.0323965204321 -86.707111991287,34.0299966128117 -86.7043120990631,34.0579955350505 -86.6843128688925,34.0543956736198 -86.7047120836665,34.0803946728416 -86.6923125609607,34.0923942109439 -86.6867127765129,34.0795947036348 -86.6687134693594,34.0835945496689 -86.6527140852229,34.107993610477 -86.622715239967,34.1227930408032 -86.6131156094851,34.1135933949248 -86.5995161329691,34.1199931485794 -86.5903164870907,34.1463921324046 -86.5455182115085,34.1855906235389 -86.5555178265938,34.1887905003662 -86.5543178727836,34.2051898691061 -86.5399184270608,34.2255890838801 -86.5235190583209,34.2263890530869 -86.5195192122867,34.2519880677053 -86.4531217681204,34.2591877905667 -86.3035275264443,34.0991939492019 -86.3323264178899,34.0463959815516 -86.3335263717002,33.9819984604022 -86.3703249552141,33.9396000924406 -86.3255266796319,33.940000077044 -86.3487257866298,33.9100012317881 -86.3423260329752,33.8868021247902 -86.4083234925382,33.8340041571398 -86.4303226457259,33.819604711417 -86.4451220760521,33.8260044650716 -86.5219191199072,33.8020053888668 -86.5775169797815,33.8020053888668 -86.5743171029542,33.7652068053529 -86.647914269982,33.7660067745598 -86.7591099897305,33.8408038953978 -86.883905185995,33.8432038030183 -86.9535025069887,33.8152048807794 -86.963502122074,33.8584032179479 -86.9623021682638,33.8676028638264 -86.947902722541,33.8616030947752 -86.9519025685751,33.8716027098605 -86.9203037849055,33.8728026636708 -86.9275035077669,33.8984016782891 -86.9167039234748,33.9156010162358 -86.8867050782189,33.9168009700461 -86.8859051090121,33.9340003079928 -86.8595061251869,33.9292004927519 -86.8331071413617,33.9491997229225</coordinates></LinearRing></outerBoundaryIs></Polygon>', '10/17/2012 1:35:07 PM')

然后将使用 POST 请求,但无论如何都会包含 INSERT 语句来查询字符串。

所以,我的问题还是一样:是否可以使用 FusionTables API .NET Client 插入大量数据?

4

1 回答 1

0

您的问题是您通过方法连接到服务器GET并且查询字符串太长。你必须使用POST来解决这个问题。POST这是您在插入/更新/删除和GET查询数据时应该使用的常见做法。

您可以阅读有关HTTP 错误 414 请求 URI 太长GET 与 POST的更多信息

于 2012-10-17T09:26:09.610 回答