我正在尝试使用 Cloud Function 运行 Google Cloud Tasks 任务,但我遇到了一个错误,我尝试使用的任何区域都是错误的。
代码是基本的。一切都很好,直到由于以下错误而停止:
错误:{"code":3,"message":"Location ' europe-west1' 不是有效位置。使用 ListLocations 列出有效位置。","details":[]}
例如,如果我尝试使用 us-central1,它将报告:
错误:{"code":3,"message":"位置必须等于 europe-west1,因为与此项目关联的 App Engine 应用位于 europe-west1 ","details":[]}
我正在使用带有 Node.js 的 Google Cloud Tasks API 来创建新任务:
const client = new CloudTasksClient({ fallback: true });
const parent = client.queuePath(PROJECT, 'europe-west1', QUEUE);
一个完整的例子可以在这里找到:https ://github.com/googleapis/nodejs-tasks/blob/master/samples/createHttpTaskWithToken.js
调用的 URL 是:“” https://cloudtasks.googleapis.com:443/$rpc/google.cloud.tasks.v2beta3.CloudTasks/CreateTask ”
如果我运行位置列表命令,这是输出:
$ gcloud tasks locations list
europe-west1 projects/[project-id]/locations/europe-west1
编辑:使用具有相同配置的 REST API ( https://cloud.google.com/tasks/docs/reference/rest/v2beta3/projects.locations.queues.tasks/create ) 可以工作。可能是客户端的bug?
我真的不确定我的设置有什么问题。
不确定哪些信息对调试有帮助,所以如果没有足够的信息,请提前道歉。