This is the code I am using to send 1 row of data to bigquery.
Assuming the following:
- Table Schema is good (works when I create a table in the ui with the same schema and the same 1 row of data)
- Map containing key:value pairs is good
- Credentials are good
- ProjectId, datasetId and tableId are correct (checked all by stepping through when it creates the url)
It always returns the response with no errors and following output: {"kind":"bigquery#tableDataInsertAllResponse"} // confirmed Status : 200
There is a possibility that the structure of my row is incorrect, but I spent lots of time breaking it apart. As I understand it
List (of TableDataInsertAllRequest.Rows objects)
TableDataInsertAllRequest.Rows Object contains a key "json" where the value is ->
Map (which contains the JSON values wanted)
List<TableDataInsertAllRequest.Rows> rowsList = new ArrayList<>(); TableDataInsertAllRequest.Rows oneRow = new TableDataInsertAllRequest.Rows(); try { Map<String, Object> objectMap = new TreeMap<>(); oneRow.setJson(objectMap); } catch (Exception e){ e.printStackTrace(); } rowsList.add(oneRow); TableDataInsertAllRequest content = new TableDataInsertAllRequest(); content.setKind("bigquery#tableDataInsertAllRequest"); content.setRows(rowsList); Bigquery.Tabledata.InsertAll request = bigqueryService.tabledata().insertAll(projectId, datasetId, tableId, content); TableDataInsertAllResponse response = request.execute();
Any ideas?