json - JSON 对象作为 BigQuery REST API 中的 GET 查询参数?
问题描述
阅读Google Cloud Platform BigQuery API https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/getQueryResults的文档,它指出formatOptions查询参数作为带有以下 JSON 的 JSON 对象传递结构体:
{
"useInt64Timestamp": boolean
}
发送一个 GET 请求,例如https://bigquery.googleapis.com/bigquery/v2/projects/{{projectId}}/queries/{{JOBid}}?maxResults=1&formatOptions={"useInt64Timestamp":true}
返回一个带有响应正文的 400 Bad Request:
{
"error": {
"code": 400,
"message": "Invalid JSON payload received. Unknown name \"formatOptions\": Cannot bind query parameter. '**formatOptions**' is a message type. Parameters can only be bound to primitive types.",
"errors": [
{
"message": "Invalid JSON payload received. Unknown name \"formatOptions\": Cannot bind query parameter. 'formatOptions' is a message type. Parameters can only be bound to primitive types.",
"reason": "invalid"
}
],
"status": "INVALID_ARGUMENT"
}
如何将formatOptions对象作为 GET 请求参数发送,如何对其进行编码以便 BigQuery API 将其识别为有效?
解决方案
解决方法是发送查询参数如下:
https://bigquery.googleapis.com/bigquery/v2/projects/{{projectId}}/queries/{{jobId}?formatOptions.useInt64Timestamp=True
推荐阅读
- javascript - 如何在递归中转换函数
- python - 为课堂外的scrapy设置开始网址
- angular - Angular Reactive Form - 从 HTML 手动更新 FormGroup
- excel - 如何使用 office-js 在任务窗格 [加载项] 中列出所有工作簿工作表?
- kibana - 从开发环境打开kibana主页失败
- swift - Swift:“'Any'类型的值没有下标”错误/ swift 5
- javascript - Webpack 构建不适用于爬虫
- laravel - 无法通过 Guzzle 请求将数据发布到 Laravel 5.4
- mongodb - 当 lambda 容器过期时,是否有关闭 mongo 连接的好方法?
- javascript - 寻求优化 parentNode 和 nextElementSibling 的使用