I'm trying to insert a row using this example code:
https://developers.google.com/bigquery/streaming-data-into-bigquery#streaminginsertexamples
I'm receiving an error:
com.google.api.client.googleapis.json.GoogleJsonResponseException: 400
{
"code" : 400,
"errors" : [ {
"domain" : "global",
"message" : "Invalid table ID \"projectid:datasetid.tableid\".",
"reason" : "invalid"
} ],
"message" : "Invalid table ID \"projectid:datasetid.tableid\"."
}
The project, dataset and table all exist. When I copy the actual projectid:datasetid.tableid from the error report and paste it into the BigQuery web UI, it works. The projectid has a '-' in it, the rest is alphanumeric. Why would the API complain about an id that the web UI accepts?
Update to answer Jordan's question. This is my call:
TableDataInsertAllResponse response =
bigquery
.tabledata()
.insertAll(projectId, datasetId, table.getId(), content)
.execute();
Before I call this, I ensure the project, dataset and table all exist by getting them. I then use the table's actual id.
New information: turns out (as you suspected) the table.getId() returns the fully qualified id, including project and dataset. When I hardcode the shortened id to exclude them, it worked.