gpt4 book ai didi

go - 上传请求无效

转载 作者:IT王子 更新时间:2023-10-29 02:18:21 26 4
gpt4 key购买 nike

尝试使用 Google API Client libraries for Go 将数据上传到 BigQuery 时,我收到以下响应.

{
"error": {
"errors": [
{
"domain": "global",
"reason": "badRequest",
"message": "Invalid Upload Request"
}
],
"code": 400,
"message": "Invalid Upload Request"
}
}

我的职位描述如下:

j := &bigquery.Job{
Configuration: &bigquery.JobConfiguration{
Load: &bigquery.JobConfigurationLoad{
DestinationTable: &bigquery.TableReference{
projectId,
"xyz",
name + "_" + yyyymmdd,
},
SkipLeadingRows: 1,
FieldDelimiter: "|",
MaxBadRecords: 3,
Schema: &bigquery.TableSchema{
[]*bigquery.TableFieldSchema{
{Name: "f1", Type: "STRING"},
{Name: "f2", Type: "STRING"},
{Name: "f3", Type: "STRING"},
{Name: "f4", Type: "STRING"},
{Name: "f5", Type: "STRING"},
{Name: "f6", Type: "STRING"},
{Name: "f7", Type: "STRING"},
{Name: "f8", Type: "STRING"},
{Name: "f9", Type: "STRING"},
{Name: "f10", Type: "STRING"},
{Name: "f11", Type: "STRING"},
{Name: "f12", Type: "STRING"},
{Name: "f13", Type: "STRING"},
{Name: "f14", Type: "STRING"},
{Name: "f15", Type: "STRING"},
{Name: "f16", Type: "STRING"},
{Name: "f17", Type: "STRING"},
},
},
},
},
}

FWIW,使用这个库的其他调用工作正常,所以我已经排除了 oauth 问题等。

编辑:我在请求发出前捕获了它。请注意,这是在 http.Client 能够添加 oauth header 之前。实际请求很大,所以我缩短了它并删除了标识符。

POST /upload/bigquery/v2/projects/.../jobs HTTP/1.1
Host: www.googleapis.com
User-Agent: google-api-go-client/0.5
Content-Length: 56369074
Content-Type: multipart/related; boundary=2220cacc03485c8143026fe3f0c40dcb1aaec8c8c2426e69adf620fc12cf

--2220cacc03485c8143026fe3f0c40dcb1aaec8c8c2426e69adf620fc12cf
Content-Type: application/json

{"configuration":{"load":{"destinationTable":{"projectId":"...","datasetId":"...","tableId":"..."},"skipLeadingRows":1,"fieldDelimiter":"|","maxBadRecords":3,"schema":{"fields":[{"name":"...","type":"STRING"},{"name":"...","type":"STRING"},{"name":"...","type":"STRING"},{"name":"...","type":"STRING"},{"name":"...","type":"STRING"},{"name":"...","type":"STRING"},{"name":"...","type":"STRING"},{"name":"...","type":"STRING"},{"name":"...","type":"STRING"},{"name":"...","type":"STRING"},{"name":"...","type":"STRING"},{"name":"...","type":"STRING"},{"name":"...","type":"STRING"},{"name":"...","type":"STRING"},{"name":"...","type":"STRING"},{"name":"...","type":"STRING"},{"name":"...","type":"STRING"}]}}}}

--2220cacc03485c8143026fe3f0c40dcb1aaec8c8c2426e69adf620fc12cf
Content-Type: text/plain; charset=utf-8

H0|H1|H2|H3|H4|H5|H6|H7|H8|H9|H10|H11|H12|H13|H14|H15|H16
f0_0|f0_1|f0_2|f0_3|f0_4|f0_5|f0_6|f0_7|f0_8|f0_9|f0_10|f0_11|f0_12|f0_13|f0_14|f0_15|f0_16
f1_0|f1_1|f1_2|f1_3|f1_4|f1_5|f1_6|f1_7|f1_8|f1_9|f1_10|f1_11|f1_12|f1_13|f1_14|f1_15|f1_16
# Three lines
# of comments
# in the trailer

--2220cacc03485c8143026fe3f0c40dcb1aaec8c8c2426e69adf620fc12cf--

最佳答案

事实证明,这是由库中的一个错误引起的,该错误没有发送所需的“uploadType”查询参数。参见 these diffs用于修复错误的补丁。

然而,这暴露了我目前正在与作者一起修复的库中的另一个错误。修复完成后,我将更新此答案。

编辑:截至this patch ,上面提到的错误已修复。

关于go - 上传请求无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10522892/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com