Christiaan Louw
Christiaan Louw

Reputation: 117

How to set content-type in Google Cloud Scheduler job

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"?

Upvotes: 1

Views: 2667

Answers (1)

John Hanley
John Hanley

Reputation: 81454

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

Upvotes: 5

Related Questions