在BigQuery API中提取作业 - 找不到作业配置对象

时间:2016-03-09 22:56:35

标签: google-bigquery extract jobs

我已经将一个提取对象传递给BigQuery,但它无法通过API识别它。但是,如果我粘贴JSON对象:

{
  "configuration": {
    "extract": {
      "sourceTable": {
        "datasetId": "data",
        "projectId": "xxxxx",
        "tableId": "s_cus_xxxx_sub_xxxxx_20160301"
      },
      "destinationUris": [
        "gs:\/\/xxxxx\/big-query-extract-20160309234218-*.csv"
      ],
      "printHeader": true,
      "fieldDelimiter": ",",
      "destinationFormat": "CSV",
      "compression": "NONE"
    }
  }
}

...进入online tester,工作完成。

任何人都可以通过我的API调用了解为什么这不起作用?这是我的请求(使用身份验证令牌遮挡)

Request: https://www.googleapis.com/upload/bigquery/v2/projects/gwt-download/jobs/

-> POST /upload/bigquery/v2/projects/gwt-download/jobs/ HTTP/1.1
-> Host: www.googleapis.com
-> User-Agent: libcurl/7.43.0 r-curl/0.9.3 httr/1.0.0 googleAuthR/0.1.2 (gzip)
-> Accept: application/json, text/xml, application/xml, */*
-> Content-Type: application/json
-> Accept-Encoding: gzip
-> Authorization: Bearer XXXXXXXX
-> Content-Length: 328
-> 
>> {"configuration":{"extract":{"sourceTable":{"datasetId":"data","projectId":"gwt-download","tableId":"s_cus_7zGNyKAXKX2pIf_sub_7zGNgXl1IQKRls_20160301"},"destinationUris":["gs://big-query-r-extracts/big-query-extract-20160309234218-*.csv"],"printHeader":true,"fieldDelimiter":",","destinationFormat":"CSV","compression":"NONE"}}}

<- HTTP/1.1 400 Bad Request
<- X-GUploader-UploadID: AEnB2UrmOHKfqva26g5PgMaWHrkzodVERv3OBk1zOLLnrNY_SGJIEWXrT8J4fYstAJ4stnVEnZMP77DQa0wwxemjPYfNR9mtsw
<- Vary: Origin
<- Vary: X-Origin
<- Content-Type: application/json; charset=UTF-8
<- Content-Length: 436
<- Date: Wed, 09 Mar 2016 22:42:19 GMT
<- Server: UploadServer
<- Alternate-Protocol: 443:quic,p=1
<- Alt-Svc: quic=":443"; ma=2592000; v="31,30,29,28,27,26,25"
<- 

错误读取:

Job configuration must contain exactly one job-specific configuration object (e.g., query, load, extract, spreadsheetExtract), but there were 0: 

2 个答案:

答案 0 :(得分:1)

产生相同错误的另一个问题是标题不是Content-Type: application/json

答案 1 :(得分:0)

复制粘贴错误,我使用的是上传网址...

https://www.googleapis.com/upload/bigquery/v2/projects/gwt-download/jobs/

而不是:

https://www.googleapis.com/bigquery/v2/projects/gwt-download/jobs/