Google apps script Google应用程序脚本和大查询-tabledate.insertAll
我们一直在努力解决这个问题。。。。。Google Apps脚本和Big Query API运行良好,但是当我尝试使用BigQuery.Tabledata.insertAll时,我总是会收到一个错误,说“没有这样的字段” 当我尝试通过GoogleAPI浏览器运行同样的东西时,它工作得很好。文档中说该命令是:Google apps script Google应用程序脚本和大查询-tabledate.insertAll,google-apps-script,google-api,google-bigquery,Google Apps Script,Google Api,Google Bigquery,我们一直在努力解决这个问题。。。。。Google Apps脚本和Big Query API运行良好,但是当我尝试使用BigQuery.Tabledata.insertAll时,我总是会收到一个错误,说“没有这样的字段” 当我尝试通过GoogleAPI浏览器运行同样的东西时,它工作得很好。文档中说该命令是: BigQuery.TableData.insertAll(TableDataInsertAllRequest resource, String projectId, String datase
BigQuery.TableData.insertAll(TableDataInsertAllRequest resource, String projectId, String datasetId, String tableId)
我已经根据文档构建了TableDataInsertAllRequest资源,它如下所示:
{
"kind": "bigquery#tableDataInsertAllRequest",
"rows":
[
{
"json":
{
"domain": "test",
"kind": "another test"
}
}
]
}
这与我的表模式相匹配
运行该命令时,返回的错误为:
{
"insertErrors": [
{
"index": 0,
"errors": [
{
"message": "no such field",
"reason": "invalid"
}
]
}
],
"kind": "bigquery#tableDataInsertAllResponse"
}
正如我所说,同一个TableDataInsertAllRequest资源在API资源管理器中工作正常(单击上面文档页面上的“尝试”),它只是无法通过应用程序脚本工作
感谢您的帮助。我也遇到过这种情况,并且在这种变化中运气更好
var rowObjects = [];
// Generally you'd do this next bit in a loop
var rowData = {};
rowData.domain = 'test';
rowData.kind = 'another test';
rowObjects.push(rowData);
// And at this point you'd have an array rowObjects with a bunch of objects
var response = BigQuery.Tabledata.insertAll({'rows': rowObjects}, projectId, datasetId, tableId);
需要注意的一些事项:
- 我没有指出
——它是通过调用种类
insertAll()
- 我使用点表示法(这是正确的术语吗?)而不是字符串将属性填充到“行对象”中
BigQuery.Tabledata.insertAll({'rows' : [
{
'domain' : 'test',
'kind' : 'another test'
}
]
},
projectId,
datasetId,
tableId);
请发布您的模式和失败的作业id。您是否使该内容正常工作?想把你的答案贴出来吗?谢谢