0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

cloud schedulerでpostするときにjson形式のparameter(パラメーター)を付与する方法

Posted at

結論

schedulerのジョブの「本文」に下記形式で設定する

{"argument": "{\"key-1\": \"val-1\", \"key-2\": \"val-2\"}"}

上記の形式で設定するとpostできます。

詳細

他には、HTTPヘッダーに下記の設定が必要です
key: Content-Type
val: application/json
image.png

あと、cloud runやfunctionsで受ける場合はjson loadsをする必要があります

@app.post(f"/post-test")
async def index(params: dict):
    params = json.loads(params["argument"])
    print(params)
    return JSONResponse(content={"result": "success"}, status_code=status.HTTP_200_OK)

他の設定は自由です。色々検索しても出てこなくて苦労したので同志向けに記載しました

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?