post a single body parameter in FastAPI

    0

    0

    Huang Brandon

    The code POSTs a JSON with a single body parameter. The Body constructor takes an arbitrary number of arguments, but only the first two are required. The embed argument indicates whether or not the body should be embedded in the response.

    # POST a JSON having a single body parameter in FastAPI
    @app.post("/do_something")
    def do_something(process_id: int = Body(..., embed=True)):
      return process_id
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.