Note that there are some explanatory texts on larger screens.

plurals
  1. PO"Invalid Upload Request" from POST
    primarykey
    data
    text
    <p>I'm trying to use the Java Apache HttpClient to send a multipart POST request to import some test data into a BigQuery table, but I keep getting HTTP 400 errors with the message "Invalid Upload Request". I'm pretty sure I followed the BigQuery tutorial well enough to reproduce what's needed, but it's not working. Could someone take a look at this request and see if anything is wrong with it?</p> <pre><code> String rawInput = "--xxx\n"; rawInput += "Content-Type: application/json; charset=UTF-8\n"; rawInput += "{\n"; rawInput += "'configuration': {\n"; rawInput += "'load': {\n"; rawInput += "'schema': {\n"; rawInput += "'fields': [\n"; rawInput += "{'name':'field1', 'type':'STRING'},\n"; rawInput += "{'name':'field2', 'type':'STRING'},\n"; rawInput += "{'name':'field3', 'type':'STRING'},\n"; rawInput += "{'name':'field4', 'type':'STRING'},\n"; rawInput += "]\n"; rawInput += "},\n"; rawInput += "'destinationTable': {\n"; rawInput += "'projectId': 'xxxxxxxxxxx [redacted]',\n"; rawInput += "'datasetId': 'test',\n"; rawInput += "'tableId': 'test'\n"; rawInput += "}\n"; rawInput += "createDisposition = CREATE_IF_NEEDED\n"; rawInput += "}\n"; rawInput += "}\n"; rawInput += "}\n"; rawInput += "--xxx\n"; rawInput += "Content-Type: application/octet-stream\n"; rawInput += "\n"; rawInput += "1,1234,11111111,1\n"; rawInput += "2,5678,11111111,1\n"; rawInput += "3,9101,11111111,1\n"; rawInput += "4,6543,11111111,1\n"; rawInput += "--xxx--"; </code></pre> <p>The request is then executed like so:</p> <pre><code> postRequest.addHeader("Content-Type", "multipart/related; boundary=xxx;"); postRequest.addHeader("Authorization", "OAuth " + credential.getAccessToken()); StringEntity input = new StringEntity(rawInput); postRequest.setEntity(input); HttpResponse response = httpClient.execute(postRequest); </code></pre> <p>Also, if I change the addHeader("Content-Type"...) to addHeader("Content-Type:"...), the error changes to "Media type 'text/plain' is not supported. Valid media types: [application/octet-stream]".</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload