0

I'm trying to insert data to BigQuery table using POST request. My application create body to request in specified format:

--xxx
Content-Type: application/json; charset=UTF-8

{
   "configuration": {
       "load": {
           "sourceFormat": "NEWLINE_DELIMITED_JSON"
       },
       "destinationTable": {
           "projectId": "some-id",
           "datasetId": "dataset-id",
           "tableId": "cards"
       }
   }
}
--xxx
Content-Type: application/octet-stream

{"board_id":1,"version":2,"card_id":1,"title":"Tytul kartki 1"}
--xxx--

but when i send this data using:

credentials = SignedJwtAssertionCredentials(
        SERVICE_ACCOUNT_EMAIL,
        key,
        scope='https://www.googleapis.com/auth/bigquery')
self.http = credentials.authorize(httplib2.Http())
headers = {'Content-Type': 'multipart/related; boundary=xxx'}
resp, content = self.http.request(url, method="POST",
                                       body=output,
                                       headers=headers)

the response from server is:

Status: {'date': 'Thu, 25 Jul 2013 12:49:06 GMT', 'status': '400', 'content-length': '205', 'content-type': 'application/json', 'server': 'HTTP Upload Server Built on Jul 12 2013 17:12:36 (1373674356)'}
Content: {
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "required",
    "message": "Required parameter is missing"
   }
  ],
  "code": 400,
  "message": "Required parameter is missing"
 }
}

I have no idea what parameter is missing. Only parameter which is required in documentation is sourceUris but i want to load data from request body not from GS.

1
  • I think you are missing setting the schema? Commented Jul 25, 2013 at 18:43

3 Answers 3

1

I think that the problem is you are missing the schema configuration:

'configuration': {
  'load': {
    'sourceFormat': <required for JSON files>',
    'schema': {
      'fields': [
        {'name':'f1', 'type':'STRING'},
        {'name':'f2', type:'INTEGER'}
      ]
    },
    'destinationTable': {
      'projectId': 'projectId',
      'datasetId': 'datasetId',
      'tableId': 'tableId'
    }
  }
}

This link maybe help you: https://developers.google.com/bigquery/loading-data-into-bigquery

Sign up to request clarification or add additional context in comments.

1 Comment

I didn't wrote the schema because it's optional parameter when we use data in JSON format specification
0

Check out the example on their loading data page. Note the project id is located in two places, both jobData and destinationTable. This might be the cause of the missing parameter error.

Comments

0

The problem is that "destinationTable" must be inside "load" object:

{
   "configuration": {
       "load": {
           "sourceFormat": "NEWLINE_DELIMITED_JSON"
           "destinationTable": {
               "projectId": "some-id",
               "datasetId": "dataset-id",
               "tableId": "cards"
           }
       }
   }
}

It can be seen in Loading Data Into BigQuery page.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.