1

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

Christiaan Louw
  • 107
  • 2
  • 11

1 Answers1

4

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

John Hanley
  • 74,467
  • 6
  • 95
  • 159
  • Thanks a lot! I ended up having to change the syntax slightly, don't know if I was doing something wrong, but the only syntax that finally worked was --headers="Content-Type=application/json" (I ended up ignoring the charset=utf-8 as it was only optional) – Christiaan Louw Nov 06 '19 at 17:11