Мы пытаемся получить/обновить таблицу Google слияния с помощью Google Api для .Net. Мы загрузили API .Net, а ниже - код. Мы можем получить информацию о таблицах, но не выполнять любые sql-запросы. Все они возвращают ошибку «Запрещено [403]». Пожалуйста, ознакомьтесь и указать нашу ошибку:Google FusionTable - API Google для .Net
Это сообщение об ошибке:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "forbidden",
"message": "Forbidden"
}
],
"code": 403,
"message": "Forbidden"
}
}
Ниже приведен код:
using Google.Apis.Auth;
using Google.Apis.Fusiontables;
using Google.Apis.Auth.OAuth2;
using Google.Apis.Fusiontables.v2;
using Google.Apis.Services;
using Google.Apis.Fusiontables.v2.Data;
var tableID = "TABLE ID";
var serviceAccountEmail = "[email protected]";
var certificate = new X509Certificate2(@"..\App_Data\API Project-d000b00dd0b0.p12", "notasecret", X509KeyStorageFlags.Exportable);
ServiceAccountCredential credential = new ServiceAccountCredential(
new ServiceAccountCredential.Initializer(serviceAccountEmail)
{
Scopes = new[] { FusiontablesService.Scope.Fusiontables }
}.FromCertificate(certificate));
FusiontablesService fusiontablesService = new FusiontablesService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName="Test"
});
Table tableData = fusiontablesService.Table.Get(tableID).Execute(); **//This code executes fine and we get back the table info(all column names).**
Try **//The Execute query throws error ‘403 – Forbidden’**
{
string query = "delete from " + tableID + " where ROWID = '407';";
var response = fusiontablesService.Query.Sql(query).Execute();
}
catch (Exception ex)
{
LogMessageToFile(ex.ToString());
}
Try **//The Execute query throws error ‘403 – Forbidden’**
{
string query = "update " + tableID + " SET Name = 'OU Pharmacy', Address = '1200 N Phillips Suite 2100 Oklahoma City OK 73104', Coordinates = '35.4792635,-97.4976772', lat = '35.4792635', lng = '-97.4976772', Phone = '405-271-2156', SFlg = '1', Marker = 'red_blank', Type = 'IIAS' where ROWID = '422';";
var response = fusiontablesService.Query.Sql(query).Execute();
}
catch (Exception ex)
{
LogMessageToFile(ex.ToString());
}
Try **//The Execute query throws error ‘403 – Forbidden’**
{
string query = "insert into " + tableID + " (Lid, Name, Address, Coordinates, lat, lng, Phone, SFlg, Type, Marker) values ('10','Bell Pharmacy','113 Boyer Ave. P.O. Box 888 Lincoln AR 72744','35.9493900,-94.4242120','35.9493900','-94.4242120','','1','NTY','grn_blank');";
var response = fusiontablesService.Query.Sql(query).Execute();
}
catch (Exception ex)
{
LogMessageToFile(ex.ToString());
}
Спасибо, Arun