将HttpRequest用作payload_type时,Google Cloud Tasks始终将HttpMethod设置为GET [英] Google Cloud Tasks always set HttpMethod to GET when using HttpRequest as payload_type

查看:124
本文介绍了将HttpRequest用作payload_type时,Google Cloud Tasks始终将HttpMethod设置为GET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据本文档[ https://cloud.google. com/tasks/docs/creating-http-target-tasks ],则应该能够创建类型为"http_request"和"http_method"设置为"POST"的任务,但是一旦任务始终使用方法"GET"创建.

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'.

在使用Python客户端库遇到此问题之后,我决定直接尝试该API,并检查它是否与库或API本身有关.

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.

使用产品文档页面中的尝试此API" [

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="
    }
  }
}

...任务已创建,方法为POST,如预期的那样.但是,如果我将请求正文设置为:

...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="
    }
  }
}

...任务已创建,但是使用的是GET方法而不是POST.

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

这就是我要排队的地方:

Here's what I get at my queue:

我相信这是一个错误,这就是为什么我在支持页面上建议使用google-apis-explorer标签在这里报告的原因.

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.

谢谢!

推荐答案

谢谢您的这篇文章,这是现有Cloud Tasks UI中的错误,我们正在修复此错误.

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.

与此同时,可以通过运行以下命令来确定任务的正确HTTP方法:

In the meantime the correct HTTP method of the task can be determined by running the following command:

gcloud beta任务描述

gcloud beta tasks describe

https://cloud.google.com/sdk/gcloud/reference/beta/tasks/describe

上面的命令将显示任务的正确HTTP方法.

The above command will show the correct HTTP method for the task.

这篇关于将HttpRequest用作payload_type时,Google Cloud Tasks始终将HttpMethod设置为GET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆