0
votes

Referencing https://cloud.google.com/bigquery/docs/reference/rest/v2/tabledata/insertAll

Google BigQuery API is returning 200 however the data is not being inserted in the table;

Request

POST https://www.googleapis.com/bigquery/v2/projects/***/datasets/***/tables/visits/insertAll?fields=insertErrors%2Ckind&key={YOUR_API_KEY}

{
 "rows": [
  {
   "json": {
    "hostId": "Value A",
    "statusCode": "Value B"
   }
  },
  {
  "insertId": "inser-id-yo",
  "json": {
  "hostId": "Value A",
  "statusCode": "Value B"
  }
 }
 ]
}

Response

Response: 200
cache-control:  no-cache, no-store, max-age=0, must-revalidate
content-encoding:  gzip
content-length:  69
content-type:  application/json; charset=UTF-8
date:  Fri, 16 Dec 2016 12:00:16 GMT
etag:  "wWvNncJfeAdSHVaIWRpICxBS7AM/vyGp6PvFo4RvsFtPoIWeCReyIC8"
expires:  Mon, 01 Jan 1990 00:00:00 GMT
pragma:  no-cache
server:  GSE
vary:  Origin, X-Origin

{
 "kind": "bigquery#tableDataInsertAllResponse"
}

My BigQuery table however is empty and no data is being inserted.

I know there a number of SDKs however I need to be able to do this via Curl as I am working in a language where Google have not developed and SDK.

2
How are you checking if the data is in the table? Note that it can take up to 90 minutes for streaming inserts to become available for copy and export operations (cloud.google.com/bigquery/streaming-data-into-bigquery), so if you are exporting the table it is possible that there is a delay.Victor Mota
Thanks @VictorMotaCiaran Synnott

2 Answers

1
votes

Anyone else who had this problem, its because BigQuery can have up to a two hour delay.

0
votes

It took me a while to find the answer. Once i got rid of the line setInsertId(String.valueOf(System.currentTimeMillis())) please see: Data streaming insertAll api usage not equal to actually inserted rows