Python 3.x 400资源名称应以“开始”/项目/<;项目ID>/&引用;
在谷歌云调度器中使用Python客户端API时,出于某种原因,我总是会收到上面的错误消息。我还尝试在没有斜杠的情况下启动父路径,但得到了相同的结果。 任何提示都将不胜感激Python 3.x 400资源名称应以“开始”/项目/<;项目ID>/&引用;,python-3.x,google-cloud-platform,google-api-python-client,google-cloud-scheduler,Python 3.x,Google Cloud Platform,Google Api Python Client,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_pa
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
参数,而是主题名的格式不正确。它应该是projects/my project id/topics/trade tests
。即使错误消息说它应该使用斜杠。但它符合API和doc
问题只是错误消息没有说明错误是关于哪个资源名称的