如何在Google Cloud Scheduler作业中设置内容类型 [英] How to set content-type in Google Cloud Scheduler job

本文介绍了如何在Google Cloud Scheduler作业中设置内容类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前有一个具有http目标和发布方法的云调度程序.

根据Google的Cloud Scheduler文档:

Content-Type:默认情况下,Content-Type标头设置为"application/octet-stream".通过在创建作业时将Content-Type显式设置为特定的媒体类型,可以覆盖默认值.例如,可以将Content-Type设置为"application/json".

我几乎需要这样做,将Content-Type设置为" application/json; charset = utf-8 ",但是我看不到这样做的方法.您如何明确地覆盖它"?

解决方案

您可以使用CLI设置标头 gcloud Scheduler Jobs create http< NAME> :

Windows命令行语法:

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

Linux命令行语法:

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

文档:

gcloud计划程序作业创建http

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

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

I currently have a cloud scheduler job with an http target and post method.

According to Google's documentation for the 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".

I need to do almost exactly this, set Content-Type to "application/json; charset=utf-8", but I see no way of doing so. How do you "override it explicitly"?

解决方案

You can set headers with the CLI gcloud scheduler jobs create http <NAME>:

Windows Command-line Syntax:

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

Linux Command-line Syntax:

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

Documentation:

gcloud scheduler jobs create http

In this answer I show another example so that you can see the options that you need to include with the command:

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

这篇关于如何在Google Cloud Scheduler作业中设置内容类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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