I am trying to create a task using Google Cloud Tasks using the Python client google-cloud-tasks==2.1.0
but I am getting an exception that HttpRequest.url is required. I am setting relative url which is a URL handling the task in my app.
The queue exists and has been created using:
gcloud task create queue notifications
The code:
client = tasks_v2.CloudTasksClient()
parent = client.queue_path(project, location, queue)
task = {
'app_engine_http_request': {
'http_method': tasks_v2.HttpMethod.POST,
'relative_uri': notification_url,
'body': payload.encode('utf-8')
},
'http_request': {
'headers': {"Content-type": "application/json"}
}
}
response = client.create_task(parent=parent, task=task)
The exact error that I receive is:
google.api_core.exceptions.InvalidArgument: 400 HttpRequest.url is required
I am trying to create task in my App Engine Standard environment.
question from:
https://stackoverflow.com/questions/65891363/cloud-tasks-app-engine-target-with-relative-uri-throws-exception-400-httpreque 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…