从Golang应用程序访问BigQuery时出现400状态码错误。

huangapple go评论85阅读模式
英文:

Hitting BigQuery from Golang app fails with 400 status code

问题

我正在尝试从Golang应用程序对BigQuery进行SQL查询,但是出现以下错误:

googleapi: Error 400: Cannot parse  as CloudRegion., badRequest

在调试请求时,我看到以下是有问题的请求:

curl --location --request POST 'https://bigquery.googleapis.com/bigquery/v2/projects/?????????/queries?alt=json&prettyPrint=false' \
--header 'Content-Type: application/json' \
--header 'User-Agent: google-api-go-client/0.5' \
--header 'X-Goog-Api-Client: gl-go/1.15.12 gccl/1.28.0' \
--data-raw '{"query":"SELECT distinct id from ?????","requestId":"request-20220308-70905360322000-0001","useLegacySql":false}

我在文档中找不到这个错误。有人可以指导我正确的方向吗?

英文:

I am trying to make a SQL query against BigQuery from a Golang applications. It does not work and throws the below error :

googleapi: Error 400: Cannot parse  as CloudRegion., badRequest

While debugging the request the library is doing I see this is the request in question:

curl --location --request POST 'https://bigquery.googleapis.com/bigquery/v2/projects/?????????/queries?alt=json&prettyPrint=false' \
--header 'Content-Type: application/json' \
--header 'User-Agent: google-api-go-client/0.5' \
--header 'X-Goog-Api-Client: gl-go/1.15.12 gccl/1.28.0' \
--data-raw '{"query":"SELECT distinct id from ?????","requestId":"request-20220308-70905360322000-0001","useLegacySql":false}

I cant find this error anywhere on the documentation. Can someone guide me in the right direction with this?

答案1

得分: 1

我知道你面临的错误有两种可能性,可能是以下两种情况之一:

  • projectId 不正确或者是一个不存在的项目。

  • 认证凭据没有正确设置,你可以查看文档中的这部分内容来进行设置。

英文:

I know that the error you are facing has two possibilities, that could be happening to you.

  • The projectId is incorrect or is a non-existing project.

  • The authentication credentials are not set up correctly, for this you
    can see this part of the
    documentation.

huangapple
  • 本文由 发表于 2022年3月9日 03:51:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/71400730.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定