From 8669fb89fef66758f8ad23210535725384a06f8e Mon Sep 17 00:00:00 2001 From: Jacob Vincent Date: Tue, 17 Mar 2020 15:04:20 -0500 Subject: [PATCH] fix #1018 --- fastapi/routing.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fastapi/routing.py b/fastapi/routing.py index b36104869648a..a0c12cbbd0286 100644 --- a/fastapi/routing.py +++ b/fastapi/routing.py @@ -127,8 +127,10 @@ async def app(request: Request) -> Response: body = await request.form() else: body_bytes = await request.body() - if body_bytes: + if body_bytes and request.headers["Content-Type"] == "application/json": body = await request.json() + else: + body = body_bytes except Exception as e: logger.error(f"Error getting request body: {e}") raise HTTPException(