Google Cloud Tasks always set HttpMethod to GET wh

2020-03-05 10:03发布

According to this documentation [ https://cloud.google.com/tasks/docs/creating-http-target-tasks ], one should be able to create tasks with type 'http_request' and 'http_method' set to 'POST', but the behavior is not the expected once the task is always created with method 'GET'.

After having this issue while using the Python Client Library, I've decided to try the API directly and check if it was an issue with the library or with the API itself.

Using the "Try this API" from the product's documentation page [ https://cloud.google.com/tasks/docs/reference/rest/v2beta3/projects.locations.queues.tasks/create ], I've tried to create similar tasks using both http_request and app_engine_http_request types and always setting the http_method to POST.

If I set the request body like this:

{
  "task": {
    "appEngineHttpRequest": {
      "httpMethod": "POST",
      "relativeUri": "/test",
      "body": "c2hhbGxvdyBub3c="
    }
  }
}

...the task is created and the method is POST, like expected. But, if I set the request body to:

{
  "task": {
    "httpRequest": {
      "httpMethod": "POST",
      "url": "https://httpstat.us/404",
      "body": "c2hhbGxvdyBub3c="
    }
  }
}

...the task is created, but with method GET instead of POST.

Here's what I get at my queue:

![Tasks in the queue.](https://drive.google.com/file/d/1cxWc43BiWDPOYekAmFMAcMZygG5dYmx6/view?usp=sharing)

I believe this is a bug, and that's why I'm reporting it here with tag google-apis-explorer as recommended at the support page.

Anyway, if anyone could tell me if I'm doing something wrong or if there's any workaround in the meanwhile I would really appreciate.

Thanks!

1条回答
狗以群分
2楼-- · 2020-03-05 10:27

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.

查看更多
登录 后发表回答