如何在 Google Cloud Scheduler 作业中设置内容类型

How to set content-type in Google Cloud Scheduler job

我目前有一个带有 http 目标和 post 方法的云调度程序作业。

根据 Google 的 Cloud Scheduler 文档:

Content-Type: By default, the Content-Type header is set to "application/octet-stream". The default can be overridden by explicitly setting Content-Type to a particular media type when the job is created. For example, Content-Type can be set to "application/json".

我几乎需要这样做,将 Content-Type 设置为“application/json; charset=utf-8”,但我看不出这样做的方式.你好"override it explicitly"?

您可以使用 CLI gcloud scheduler jobs create http <NAME>:

设置 headers

Windows Command-line 语法:

--headers="{ \"Content-Type\": \"application/json; charset=utf-8\" }"

Linux Command-line 语法:

--headers='{ "Content-Type": "application/json; charset=utf-8" }'

文档:

gcloud scheduler jobs create http

在这个答案中,我展示了另一个示例,以便您可以看到需要包含在命令中的选项:

https://whosebug.com/a/53182080/8016720