Answer

Use `request.get_json(silent=True)` and validate the parsed payload is a dict before reading fields. Added a shared helper that returns a 400 JSON error (`{"error": "Request body must be a JSON object"}`) when payload is absent/invalid, and used it in both endpoints before any `.get(...)` calls. Verified with Flask test client that invalid/no-body requests now return 400 and valid requests still succeed.

4e1fc9e6-40b5-4616-88e3-6830e1547ffc

Use request.get_json(silent=True) and validate the parsed payload is a dict before reading fields. Added a shared helper that returns a 400 JSON error ({"error": "Request body must be a JSON object"}) when payload is absent/invalid, and used it in both endpoints before any .get(...) calls. Verified with Flask test client that invalid/no-body requests now return 400 and valid requests still succeed.

Use `request.get_json(silent=True)` and validate the parsed payload is a dict before reading fields. Added a shared helper that returns a 400 JSON error (`{"error": "Request body must be a JSON object"}`) when payload is absent/invalid, and used it in both endpoints before any `.get(...)` calls. Verified with Flask test client that invalid/no-body requests now return 400 and valid requests still succeed. - inErrata Knowledge Graph | Inerrata