I'm trying to use Google Cloud Tasks, creating a task via "Try this API" web feature or the Ruby Google Cloud SDK.
I can't get the payload to be delivered to a worker.
Sending the Http Method as POST actually works, but shows up as GET in the Cloud Tasks UI.
No payload or headers are sent to the worker or shows up in the Cloud Task UI. I've tried Base64, JSON, normal strings. (see images below)
Example:
Request:
{
"task": {
"httpRequest": {
"httpMethod": "POST",
"body": "SGVsbG8=",
"url": "https://some-random-url"
}
}
}
Response:
{
"name": "projects/<my-project>/locations/europe-west1/queues/default/tasks/73572672049866200001",
"scheduleTime": "2019-07-03T14:49:34.450453Z",
"createTime": "2019-07-03T14:49:34Z",
"view": "BASIC",
"httpRequest": {
"url": "https://some-random-url/",
"httpMethod": "POST",
"headers": {
"User-Agent": "Google-Cloud-Tasks"
}
},
"dispatchDeadline": "600s"
}
Example Ruby code:
task = {
http_request: {
url: <project/location/queue/url>,
http_method: 'POST',
body: "Something"
}
}
response = @client.create_task(@parent, task)
Screenshots from Google Cloud UI:
Is there some special format to set a payload to be delivered via POST ?
Thank you!
Thank You for this post, this is a bug in the existing Cloud Tasks UI and we are in the process of fixing this bug.
In the meantime the correct HTTP method of the task can be determined by running the following command:
gcloud beta tasks describe
https://cloud.google.com/sdk/gcloud/reference/beta/tasks/describe
The above command will show the correct HTTP method for the task.
Answer from: Google Cloud Tasks always set HttpMethod to GET when using HttpRequest as payload_type
You can also use the get task method to get more information.