/"开头-6ren"> /"开头-在为 Google Cloud Scheduler 使用 Python 客户端 API 时,出于某种原因,我总是收到上述错误消息。我也尝试在没有斜杠的情况下启动父路径,但得到了相同的结果。非常感谢任何-6ren">
gpt4 book ai didi

python-3.x - 400 资源名称应以 "/projects//"开头

转载 作者:行者123 更新时间:2023-12-05 03:01:18 25 4
gpt4 key购买 nike

在为 Google Cloud Scheduler 使用 Python 客户端 API 时,出于某种原因,我总是收到上述错误消息。我也尝试在没有斜杠的情况下启动父路径,但得到了相同的结果。非常感谢任何提示!

import os
from google.cloud import scheduler_v1

def gcloudscheduler(data, context):
current_folder = os.path.dirname(os.path.abspath(__file__))
abs_auth_path = os.path.join(current_folder, 'auth.json')
os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = abs_auth_path


response = scheduler_v1.CloudSchedulerClient().create_job(data["parent"], data["job"])
print(response)

我使用了以下参数:

{"job": {
"pubsub_target": {
"topic_name": "trade-tests",
"attributes": {
"attrKey": "attrValue"
}
},
"schedule": "* * * * *"
},
"parent": "/projects/my-project-id/locations/europe-west1"
}

最佳答案

问题实际上不是 parent 参数,而是 topic-name 的格式不正确。它应该是 projects/my-project-id/topics/trade-tests。即使错误消息说它应该带有斜线。但是符合API文档herehere .

问题只是错误消息没有说明错误与哪个资源名称有关。

关于python-3.x - 400 资源名称应以 "/projects/<PROJECT_ID>/"开头,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55990431/

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