Help us understand the problem. What is going on with this article?

[GCP] Cloud SchedulerからGraphQLAPIが叩けない = gloudコマンドでヘッダを設定しなさい。

状態

厳密には、叩けているけど、何にも実行されない。
status:200が返ってくる状態。

解決策

ヘッダがコンソールからだと設定できないみたいなので、gcloudコマンドから設定する。
以下参照してね。
【GCP】Cloud Scheduler を使ってみた

gcloud beta scheduler jobs create http send-mail \
--time-zone "Asia/Tokyo" \
--schedule="0 9 * * *" \
--uri="https://hogehoge.appspot.com/graphql" \
--headers="Content-Type=application/json" \
--http-method="POST" \
--message-body="{ \"query\": \"query { sendMailResolver }\"}"

queryについて

sendMailResolver
という、メールを送信するQueryがあるとする。

まず、ローカルでcurlを実行してみる。

curl \
  -X POST \
  -H "Content-Type: application/json" \
  --data "{ \"query\": \"query { sendMailResolver }\"}" \
  http://localhost:3000/graphql

Booleanを返す。APIです。

ローカルの実行結果

Parameters: {"query"=>"query { sendMailResolver }", "graphql"=>{"query"=>"query { sendMailResolver }"}}

GAEログ

Parameters: {
"operationName"=>"SendMailResolver", 
"variables"=>{}, 
"query"=>"query SendMailResolver {
\n  sendMailResolver\n}\n", 
"graphql"=>{"operationName"=>"SendMailResolver", 
"variables"=>{}, 
"query"=>"query sendMailResolver {\n  sendMailResolver\n}\n"}
}
Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away