如何解决发布到Cloud Dataflow模板REST API时无法设置动态模板
我正在尝试通过Cloud Scheduler计划数据流作业,方法是发布到REST API并由OAUTH进行身份验证。我已经创建了一个模板,当我手动使用Dataflow“从模板创建作业”时,它可以工作。但是,当用作HTTP端点(https://dataflow.googleapis.com/v1b3/projects/${my.proj}/locations/europe-west1/templates:launch?gcsPath=gs://${my.proj}/templates/${template.name})时,它返回以下错误:
{
"error": {
"code": 400,"message": "Invalid JSON payload received. Unknown name \"jobName\": Cannot bind query parameter. Field 'jobName' could not be found in request message.\nInvalid JSON payload received. Unknown name \"environment\": Cannot bind query parameter. Field 'environment' could not be found in request message.\nInvalid JSON payload received. Unknown name \"parameters\": Cannot bind query parameter. Field 'parameters' could not be found in request message.","status": "INVALID_ARGUMENT","details": [
{
"@type": "type.googleapis.com/google.rpc.BadRequest","fieldViolations": [
{
"description": "Invalid JSON payload received. Unknown name \"jobName\": Cannot bind query parameter. Field 'jobName' could not be found in request message."
},{
"description": "Invalid JSON payload received. Unknown name \"environment\": Cannot bind query parameter. Field 'environment' could not be found in request message."
},{
"description": "Invalid JSON payload received. Unknown name \"parameters\": Cannot bind query parameter. Field 'parameters' could not be found in request message."
}
]
}
]
}
}
以下是我的POST正文:
{
"jobName": "test","parameters": {
"region": "europe-west1"
},"environment": {
"tempLocation": "gs://${my.proj}/temp","zone": "europe-west1"
}
}
感谢您的帮助,谢谢!!
解决方法
我验证了以下功能:
TEMPLATE_LOCATION="gs://${my.proj}/templates/${template.name}"
API_ROOT_URL="https://dataflow.googleapis.com/"
TEMPLATES_LAUNCH_API="${API_ROOT_URL}/v1b3/projects/${my.proj}/locations/europe-west1/templates:launch"
time curl -X POST -H "Content-Type: application/json" \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"${TEMPLATES_LAUNCH_API}"`
`"?gcsPath=${TEMPLATE_LOCATION}"`
` -d '
{
"jobName": "test","parameters": {},"environment": {
"tempLocation": "gs://${my.proj}/temp","workerZone": "europe-west1-d",}
}'
请注意,您无需在参数中指定区域,它是workerZone而不是zone。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。